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!

[ The PC Guide | Systems and Components Reference Guide | Keyboards | Keyboard Software Issues ]

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:

  • The "<d>" number for delay can be 1, 2, 3 or 4, where the delay is a quarter of a second times the number. So 4 means a delay of 1 full second before a key begins repeating; 1 means 0.25 seconds. This number is approximate.
  • The "<r>" number is from 1 to 32 and should represent the repeat rate in characters per second, but it doesn't. :^) Instead, a strange algorithm is used, which causes most of the numbers to be "clumped" towards the low end of the range, instead of it being linear. The table below shows the rates for the different settings:

Rate #

Approximate Rate (cps)

Rate #

Approximate Rate (cps)

Rate #

Approximate Rate (cps)

Rate #

Approximate Rate (cps)

1

2.0

9

4.0

17

8.0

25

16.0

2

2.1

10

4.3

18

8.6

26

17.1

3

2.3

11

4.6

19

9.2

27

18.5

4

2.5

12

5.0

20

10.0

28

20.0

5

2.7

13

5.5

21

10.9

29

21.8

6

3.0

14

6.0

22

12.0

30

24.0

7

3.3

15

6.7

23

13.3

31

26.7

8

3.8

16

7.5

24

15.0

32

30.0

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 by 20%.

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:

Rate = (240) / ( (8+Y) * (2^Z) )

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.

Next: Windows Keyboard Controls and Multiple Layout and Language Support


Home  -  Search  -  Topics  -  Up

The PC Guide (http://www.PCGuide.com)
Site Version: 2.2.0 - Version Date: April 17, 2001
Copyright 1997-2004 Charles M. Kozierok. All Rights Reserved.

Not responsible for any loss resulting from the use of this site.
Please read the Site Guide before using this material.
Custom Search