Learn about the technologies behind the Internet with The TCP/IP Guide!|
NOTE: Using robot software to mass-download the site degrades the server and is prohibited. See here for more.
Find The PC Guide helpful? Please consider a donation to The PC Guide Tip Jar. Visa/MC/Paypal accepted.
|View over 750 of my fine art photos any time for free at DesktopScenes.com!|
DOS Keyboard Controls
Most people don't directly use DOS much any more; however, it still underlies Microsoft's consumer operating systems (much as they hate to admit this to anyone.) Therefore, one still must deal with it on occasion. And of course, there are plenty of older PCs out there still running DOS, perhaps in combination with Windows 3.x.
The first thing to know about DOS's handling of the keyboard is that it knows the keyboard by a special name. Much as your first parallel printer port is "LPT1:", and your serial ports "COM1:" and "COM2:", DOS considers your keyboard and monitor, combined, to be the console, and names it "CON:". This name is a throwback to the "olden dayse" of computer terminals. :^) When you take input from "CON:" it comes from the keyboard; when you send output to it, it goes to the screen.
Tip: Need to create a short file
and don't have an editor handy? From the DOS prompt, type "copy
con: <filename>" and hit <Enter>. Then enter the lines of the
batch file, hitting <Enter> after each one. When done, enter <Ctrl>+Z on a
line by itself and hit <Enter>. DOS will "copy" from the keyboard to the
file, creating it for you with no editor required. (If you then type "copy <filename> con:" it will display the file on the
screen, though the built-in DOS "TYPE" command is easier.)
The tip above aside, you won't generally use "CON:" but it's still good to know it's there. There's also a DOS command designed specifically to manage certain settings associated with the "console": the "MODE" command. To see what this command is about, boot to DOS, or open a DOS window, and type "mode /?" to see the command's various options.
As you see, "MODE" is used for changing settings for many different system devices. For "CON:" you can see that it can be used to set the number of columns and rows of the display (for DOS programs), or the typematic rate for the keyboard (see the section on the Typematic feature for more in general terms on that feature.). We are of course concerned with the keyboard here; to set the typematic controls, from DOS enter this command: "mode con: delay=<d> rate=<r>", where <d> and <r> are numbers for the typematic delay and repeat rate, respectively:
Note: Don't be fooled by these
precise-sounding numbers; they are precise because they come from a mathematical equation
(see below) but any given system can implement repeat rates be above or below these values
So where do these numbers come from? A weird formula. Take the rate number, subtract 1, convert it to a binary number and then exclusive-or the bits to negate them, resulting an a five-bit binary number. Then take the two high-order bits and call their value "Z", and the three low-order bits and call them "Y". The repeat rate then is simply:
So take "21" for example, the default value for many systems. Subtract one to get 20, which in binary is 10100. Invert that to get 01011. The two high-order bits are 01, so Z is 1, and the low-order bits are 011, so Y is 3. So the repeat rate is 240 / ((8+3) * (2^1)) = 240 / (11*2) = 10.9. Now, aren't you glad you asked? ;^) Why did they do all of this instead of just saying that the rate number was the value in characters per second? Well, engineers need to make a living too, don't they? ;^)
Today, the use of the "MODE" command has mostly been replaced by equivalent Windows controls and settings. However, in some cases you may want to set the typematic controls within DOS. Note that the Windows settings for these values use the same bizarre numbering schemes, just hidden under a graphical Windows control. :^)
Another useful DOS control for the keyboard is the "NUMLOCK" command. In DOS versions 6 or higher, you can put a line such as "NUMLOCK=ON" or "NUMLOCK=OFF" in the system's CONFIG.SYS file. This will cause the system to set the <Num Lock> status of the keyboard accordingly. There are also public-domain software utilities that will do the same thing, if you don't want to do it within CONFIG.SYS.