Jan 022018
Outstanding key-scan prog & .DOC.
File KEYS310.ZIP from The Programmer’s Corner in
Category Utilities for DOS and Windows Machines
Outstanding key-scan prog & .DOC.
File Name File Size Zip Size Zip Type
KEYS310.DOC 29165 9369 deflated
KEYS310.EXE 19153 11507 deflated
KEYS310.PIC 1763 524 deflated
KEYS310.RVU 1792 809 deflated

Download File KEYS310.ZIP Here

Contents of the KEYS310.DOC file

More than WE ever wanted to know about keyboards

Keyboards for the original IBM PC had 83 keys and an INTEL 8048
microprocessor contained within the keyboard itself. This keyboard
processor detected when a key was physically pressed or released and
signaled the PC by sending a Keyboard Scan Code. Keyboard Scan Codes
were assigned by numbering the physical keys on an original IBM 83 Key
keyboard from left to right top to bottom starting with the Esc key(1)
through Caps Lock(58), F1(59) through F10(68) and the 15 numeric
keypad keys Num Lock(69) through Del(83).

The PC's Read Only Memory Basic Input Output Service (ROM BIOS)
converted the IBM unique Keyboard Scan Code to the American Standard
Code for Information Interchange (ASCII) which is used for data
representation by many of the world's computers, including the PC.
The keystroke's ASCII/IBM interpretation could be acquired by the
user's program using the Disk Operating System's (DOS) services or the
ROM BIOS's services. Keys that had no corresponding ASCII graphic
symbol (like the cursor positioning keys or the function keys) were
assigned a value of ASCII Nul (zero/blank) which signals that the next
byte is a scan code and not an ASCII code. The Keyboard Scan Code was
made available via interrupt services to those programs wishing to
detect non-ASCII keys such as the Cursor or Function Keys.

Other companies produced keyboards as replacements or "improvements."
Some of these followed the 83-key layout from the original IBM PC
keyboard. Others used different positioning or added different
arrangements of keys in an attempt to make the use of the keyboard
more convenient. Two examples of this type of keyboard are the
Keytronics "5151" 88-key keyboard and the Honeywell "Enhanced" 116-key
keyboard. Each manufacturer added additional keys so that some of the
keystrokes that were done on the IBM 83-key keyboard with the use of
the shift, alt or control keys could be done with a single keystroke.
The "5151" added a keypad for cursor control. The "Enhanced" added a
keypad for cursor control and 20 additional function keys to duplicate
the results of the Shift'ed-Function Keys and Controll'ed-Function
Keys. In both cases, the manufacturer had the keyboard's
microprocessor map the additional keys into the original IBM scan
codes so that no BIOS or user program changes would have to be made.

IBM PC or compatible Clone owners could simply purchase one of these
new keyboards to replace the standard IBM keyboard. For example, the
"5151" directly replaces the 83 key IBM keyboard with no hardware or
software changes required. In fact, when using one of these
keyboards, a program can not tell if an "Enter" scan code came from
the alphabetic keypad or from the numeric keypad. Both keys produce
the same results when viewed by the computer's BIOS.

Other keyboards, like the Honeywell "Enhanced" keyboard were designed
to work with a specific compatible BIOS and so are not used for direct
plug-for-plug replacements. However, they are functional
replacements. User programs cannot easily detect that the keyboard
uses a different identification byte when the CPU resets the keyboard
during the Power-On-Self-Test (POST) when you boot.

10 June 1988 KEYS 3.10 Page 1

More than WE ever wanted to know about keyboards

With the AT, IBM introduced the 84-key keyboard, adding the "Sys Req"
key, as well as ROM BIOS support for it. This "System Request" key is
interpreted by programs that detect it, such as Microsoft CodeView, to
signal a request for the systems attention outside of normal
processing. This technique is less prone to error than using the
Break signal. If there is no program to accept a Break, DOS simply
aborts the user program, which can cause loss of files and data. If
there is no program to accept a Sys Req, it is effectively ignored by

Later the 101-key keyboard was introduced by IBM. This time a change
was made to the keyboard microcode and to the ROM BIOS to allow
programs to differentiate between the normal (original 83) and the
extended keys (the new 18). This is done by providing two new
function calls to the BIOS Interrupt Service which return a flag byte
indicating that the key pressed is considered to be an extended key.
Most programs written before the extended BIOS was released do not use
these new function calls. It would be confusing for you to remember
to use the numeric keypad cursor keys with an older program but the
cursor pad cursor keys with a newer program. The extended BIOS
maintains the capability to run these older programs unchanged, while
it allows the use of the new keys on the 101-key keyboard with older
programs. The extended BIOSs original functions return exactly the
same code for both the normal and extended keys marked with the same
symbol. An "old" program using these original BIOS functions (no
matter what the hardware) can detect, for example, that a cursor key
is pressed but not which keypad has been used. But a "new" program
can test to see if the extended BIOS is present and, if it is, the
program can use the new BIOS functions to detect that the key pressed
is one from the original keyboard numeric pad or one from an extended
cursor pad.

BIOS INT 16H functions:

o 00H Read character from keyboard
o 01H Read keyboard status
o 02H Return keyboard flags
o 10H Extended Read character from keyboard
o 11H Extended Read keyboard status

In May 1988 Jeff Morley, a DC area SysOp, commented that KEYS21 (a
program we had written and distributed in 1986 to show the results of
keypress combinations so that "hot keys" could be properly configured)
did not differentiate between normal and extended keys. Jeff went on
to point out that Microsoft QuickBASIC could differentiate between
Home and Extended Home by setting a bit in the KEYS command and he
provided a code sample to show how to do it. KEYS310 and this article
are a result of the ongoing investigation into "What happens when I
press these keys?"

10 June 1988 KEYS 3.10 Page 2

More than WE ever wanted to know about keyboards

By trial, error and BIOS disassembly, we determined that the general
logic flow used to read the keyboard is:

A key is pressed or released

The microprocessor within the keyboard sends a serial signal to
the serial-to-parallel converter on the motherboard.

Logic on the motherboard detects this signal and decodes it into
a scan code that is placed in a register at port 60H (some
mapping may occur here for keyboards with more than the original
83 keys).

A BIOS INT 09H is generated as a result of either the key press
or the key release. INT 09H is handled by code contained in the
ROM BIOS tailored specifically for the hardware environment
designed by the manufacturer.


o acknowledges receipt of the keystroke to the keyboard.

o if the keys pressed are Shift-PrtSc, INT 05H is generated
and the keys are not passed on to the circular buffer.

o if the key pressed is Control Break, INT 1BH is generated
and the scan code is set to zero and the ASCII
representation is set to zero and placed in the circular

o if the keys pressed are Ctrl-Alt-Del, the machine is

o if the keys pressed are Ctrl-NumLock, the machine is
"Paused" (answering interrupts but otherwise processing
waits for another keystroke).

o if an Extended BIOS is present, INT 15H or inline code takes
action on the Extended keys.

o otherwise, if the keypress combination is determined to be
valid; both the scan code and the BIOS translated ASCII
representation are placed in the 16-character keyboard
buffer making them available to BIOS INT 16H.

User programs use DOS INT 21H to call BIOS INT 16H or use BIOS
INT 16H directly to read the keystroke(s) out of the buffer.

KEYS21 has evolved into what we are releasing as KEYS310. KEYS310
uses the new function calls if the presence of an Extended BIOS is
detected. KEYS310 reports in its Int 09H window the nominal keytop,
press/release indicator, keyboard scan codes and the BIOS maintained
keyboard status at that instant of ALL keys as they are
pressed/released. Some of the Int 09H techniques are derived from the

10 June 1988 KEYS 3.10 Page 3

More than WE ever wanted to know about keyboards

program KEYSCOPE1.1. Duplicate keystroke suppression has been
implemented at the suggestion of John Van Lund. It also reports in
its Int 16H window the ASCII and IBM graphical interpretation of only
those keys processed by the BIOS into what is by default a 16-key
circular buffer (unless you have installed one of the many keyboard
accelerators that enlarge this buffer) and signaled via BIOS Int 16h.
It has been tried on both IBM keyboards and clones and on several
differing BIOSs. It has detected several unusual BIOS/Keyboard
results which are documented in Appendix A.

To aid in identifying sources of irregularities, KEYS310 reports the
Model and BIOS Release Date of the machine upon which it is executed.
We would be most interested to see error reports if you come up with a
combination we haven't tested or something we have overlooked. PrtSc
has been left enabled so that screens may be captured to a printer or
disk file. [Use LPTX or PRN2FILE to capture the screen image for
submission via a local BBS to Mike. You can leave messages to Mike
Focke on almost any PC/MS-DOS oriented DC area BBS. Or just send the
hardcopy to:

Mike Focke
3599 Twilight Court
Oakton, VA 22124.

To aid in the identification of your BIOS, you may wish to run PC-
IDENT from INFO-175.ARC available from your local BBS.]

KEYS310 uses ANSI.SYS functions so "Device=ansi.sys" or its equivalent
must be in your CONFIG.SYS file. Interaction with keyboard or video
accelerators (TSRs) may confuse KEYS310. If the screen results do not
match your expectations, you may wish to eliminate those TSRs that
grab keystrokes or speed up screen writes. Quickeys and Zeno13 have
both been found to interfere with proper operation of KEYS310.

One of the interesting results of our investigation of "what happens
when I press these keys?" is that the answer is: "It depends!" The
keys passed by BIOS Int 09H to the circular buffer vary according to
the standards set by the BIOS manufacturer. They even differ from
BIOS revision to BIOS revision. Only by testing with a program such
as KEYS310 can you determine whether your machine meets the minimum
original 83-key standard or the 84-key standard or the 101/102-key
standard. Our testing has encountered at least one surprise on every
keyboard. Test yours to see what you might learn.

KEYS310 program is freeware. It borrows freely from other authors
code and concepts. KEYS310 is my way of saying thank you to Mike
Focke and the DC area PC Bulletin Boards for bits of code, programs,
answers to questions, beta testers, etc.


10 June 1988 KEYS 3.10 Page 4

More than WE ever wanted to know about keyboards


BIOS Bugs and Other Irregularities

Testing on a Dell Model 200 AT Clone with a Phoenix BIOS 3.07 10 and a
101-key keyboard uncovered:

o Phoenix/Dell has assigned scan codes to control and alternate
numeric keypad keys that had not been previously assigned. Scan
codes 8D hex through A6 hex are reported by KEYS310 to exactly
describe that particular configuration. (See Appendix D.)

o There is a key labeled "Pause" that produces the Control-NumLock
effect. This key also generates a new scan code 225 decimal E1
hex seen only by Int 09H. KEYS310 documents this keytop as

o This keyboard/BIOS combination does not properly handle a
Control \ [FS] keypress, it returns ASCII 0 00H, Scan Code 28 1CH
(Alternate Carriage Return [Enter]) instead of ASCII 28 1CH,
Scan Code 43 2BH (Control \ [FS]). KEYS310 has been validated
against this machine and now properly reports all other
keypresses. Control \ [FS] is properly reported when run against
other machines.

Testing on a Dell Model 100 Turbo PC Clone with an 84-key keyboard
uncovered that the Sys Req key is not properly detected or reported by
the "Standard" BIOS shipped with that machine. KEYS310 and the Dell
Keyboard Diagnostic report a Left Shift when the Sys Req key is

Testing by John Van Lund in Tennesse uncovered that the predecessor to
KEYS310 would crash when run on an original IBM XT with a BIOS dated
November 1982. KEYS310 has been tested by John and no longer crashes
on his benchmark machine. John also suggested that we supress the
near real-time INT 09H display of keys pressed when the only
information gained is that you are holding down a key. Per John's
suggestion KEYS310 only displays INT 09H keys detected when the keys
or status are different.

Testing a Honeywell AP / ROM BIOS 4-5 with Enhanced 116-key keyboard
produced "Unexpected Results" when some multikey combinations are

o Control-Alt-NumLock produces "Alternate Grey *"
[a legal keypress on the Dell Model 200 described above]

o Control-Alt-ScrollLock produces "Unexpected Alt"
[the Alt key is never expected to be seen by BIOS Int 16H]

These are unexpected/irregular because the scan codes don't match the
keys depressed nor do they match the IBM technical reference or the
Microsoft MASM documentation.

10 June 1988 KEYS 3.10 Page 5

More than WE ever wanted to know about keyboards


For Hackers Only (Implementation Historical Notes)

Using Jeff's QuickBASIC example and compiling it with QuickBASIC 4.0
on a Honeywell AT-clone (the AP with Honeywell/NCR BIOS 4-2) with an
Enhanced 116-key keyboard, Jeff's example failed to detect the
difference between the cursor pad "home" key and the numeric pad
"home" key. When the program was compiled with code to detect the
function keys F11 and F12, the compiler issued an error message
"illegal function call" for the "KEY 30 ON" statement. Using the same
program but compiling it with the QuickBASIC 3.0 that was on a Dell
Model 200 AT-clone with a Phoenix BIOS 3.07 and a 101 key keyboard,
Jeff's program did detect the difference between the two "home" keys
and also detected the new function keys F11 and F12. KEYSCOPE1.1 from
Pierpoint Software was then used and it pointed towards the presence
of the Extended BIOS as a significant difference.

We learned that QuickBASIC 4.0 apparently determines the availability
of the Extended BIOS on the compiling machine and will not allow
interactive execution of the KEY (30) ON statement if there is no
possibility of detecting it. We decided that KEYS21 was functioning
as well as any program could, that does not use the Extended INT 16H
functions to query for extended keys.

The following BIOS/DOS interrupts have been captured/released by
KEYS310 to provide its current functionality:

Int 05H Print Screen Interrupt
Int 09H Keyboard Interrupt
Int 15H Cassette (SysReq) Interrupt
Int 1BH Control Break Interrupt
Int 23H DOS Control C Interrupt

These interrupts were trapped by installing alternate user-written (in
Microsoft Macro Assembly Language 5.0 [MASM]) interrupt handlers that
logged the event and then either allowed DOS to process the event
normally (as in the case of a keypress) or to ignore the event (as in
the case of Control Break). Using this technique even a Control-Alt-
Delete reboot could be detected and reported without allowing the
reboot to take place, but that functionality is not included in this
release, nor is it planned. Nor have we planned to measure the amount
of time that the Control-NumLock combination has been activated to
inform you that you just "Paused" the processor for seconds.
Interaction with Int 09H is not advised for the faint hearted. If a
mistake is made the only recourse is a Hardware Reset (if your machine
is so equipped) or THE BIG RED SWITCH. C 5.0 will allow C programs
to be attached as chained interrupt handlers by using chain_intr or to
capture selected interrupt vectors with dos_getvect and dos_setvect.
KEYS310 uses only the ability to call MASM routines from C.

10 June 1988 KEYS 3.10 Page 6

More than WE ever wanted to know about keyboards

Several DOS Features have been disabled by setting the console into
"raw" mode by flipping one bit in the BIOS device driver table:

o "Control P"/"Control Print Screen" Printer Logging

keeps KEYS310 from displaying ANSI cursor positioning
sequences on your printer when you were simply try to see
what code was generated by pressing the key.

o "Control S" Screen Pause

keeps you from wondering "What Happened?" when you press
Control S and nothing happens until you press another key.

o "Control C" Control Break Equivalent

prevents DOS from displaying Control C (^C) on the screen
wherever the cursor happened to be at the time. The code to
look for a Control C interrupt is still active but it should
never report the event.

KEYS310 development required the following resources:

Manufacturers BIOS Listings
Sourcer Generated BIOS Listings
Sourcer Generated KEYSCOPE Listing
Manufacturers Technical References
Ray Duncan "Advanced MS DOS"
Robert Jourdain "Programmer's Problem Solver for
the IBM PC, XT & AT"
W. David Schwaderer "C Wizard's Programming Reference"

The commercially available disassembler Sourcer V1.70 has proven to
generate very usable Assembly Language from a variety of BIOSs and
assorted .COM/.EXE files.

10 June 1988 KEYS 3.10 Page 7

More than WE ever wanted to know about keyboards



KEYS310 documents some of the more exotic keyboard to CPU codes:

o KB Ack Keyboard Acknowledgement to the PC
o Par Err Command received from system was invalid, or byte was
received with incorrect parity
o Mem Err Keyboard RAM or ROM error
o Mat Err Keyboard Matrix Error
o KeyRlsd Key released

according to the technical reference for the Honeywell AP.

Operation of KEYS310 uncovered:

o Pause The Key Used by Dell/Phoenix to initiate a Control-
NumLock "Pause"

10 June 1988 KEYS 3.10 Page 8

More than WE ever wanted to know about keyboards


Interrupt 16H ASCII/Scan Codes Expected by KEYS310

Norm Shft Ctrl Alt Keytop Unshifted Shifted
==== ==== ==== ==== ====== ============= =================
---- ---- 0000 ---- Break (Control Scroll Lock)
1B01 1B01 1B01 0001* Esc
3102 2102 ---- 0078 1 ! exclamation
3203 4003 0003 0079 2 @ at sign
3304 2304 ---- 007A 3 # pound sign
3405 2405 ---- 007B 4 $ dollar sign
3506 2506 ---- 007C 5 % percent
3607 5E07 1E07 007D 6 ^ caret
3708 2608 ---- 007E 7 & ampersand
3809 2A09 ---- 007F 8 * asterisk
390A 280A ---- 0080 9 ( left parenthesis
3A0B 290B ---- 0081 0 ) right parenthesis
2D0C 5F0C 1F0C 0082 - _ minus sign underscore
3D0D 2B0D ---- 0083 = + equal sign plus sign
080E 080E 7F0E 000E* Backspace
090F 000F 0094* 00A5* Tab
7110 5110 1110 0010 q Q
7711 5711 1711 0011 w W
6512 4512 0512 0012 e E
7213 5213 1213 0013 r R
7414 5414 1414 0014 t T
7915 5915 1915 0015 y Y
7516 5516 1516 0016 U U
6917 4917 0917 0017 i I
6F18 4F18 0F18 0018 o O
7019 5019 1019 0019 p P
5B1A 7B1A 1B1A 001A* [ { left bracket left brace
5D1B 7D1B 1D1B 001B* ] } right bracket right brace
0D1C 0D1C 0A1C 001C* Carriage Return [Enter]

Control Key (Scan code 1D)

611E 411E 011E 001E a A
731F 531F 131F 001F s S
6420 4420 0420 0020 d D
6621 4621 0621 0021 f F
6722 4722 0722 0022 g G
6823 4823 0823 0023 h H
6A24 4A24 0A24 0024 j J
6B25 4B25 0B25 0025 k K
6C26 4C26 0C26 0026 l L
3B27 3A27 ---- 0027* ; : semicolon colon
2728 2228 ---- 0028* ' " apostrophe quote
6029 7E29 ---- 0029* ` ~ grave accent tilde

Left Shift (Scan Code 2A)

10 June 1988 KEYS 3.10 Page 9

More than WE ever wanted to know about keyboards

Interrupt 16H ASCII/Scan Codes Expected by KEYS310

Norm Shft Ctrl Alt Keytop Unshifted Shifted
==== ==== ==== ==== ====== ============= =================
5C2B 7C2B 1C2B 002B* \ | back slash vertical bar
7A2C 5A2C 1A2C 002C z Z
782D 582D 182D 002D x X
632E 432E 032E 002E c C
762F 562F 162F 002F v V
6230 4230 0230 0030 b B
6E31 4E31 0E31 0031 n N
6D32 4D32 0D32 0032 m M
2C33 3C33 ---- 0033* , < comma less than sign
2E34 3E34 ---- 0034* . > period greater than sign
2F35 3F35 ---- 0035* / ? slash question mark

Right Shift (Scan Code 37)

2A37 INT5 0072 ---- PrtSc *

Alt Key (Scan Code 38)

2039 2039 2039 2039 Space Bar
CL CL ---- CL Caps Lock (Scan Code 3A)
003B 0054 005E 0068 F1
003C 0055 005F 0069 F2
003D 0056 0060 006A F3
003E 0057 0061 006B F4
003F 0058 0062 006C F5
0040 0059 0063 006D F6
0041 005A 0064 006E F7
0042 005B 0065 006F F8
0043 005C 0066 0070 F9
0044 005D 0067 0071 F10
NL NL Pause NL Num Lock (Scan Code 45)
SL SL Break SL Scroll Lock (Scan Code 46)

Cursor Pad Keys (Used to enter ASCII codes 001-255
as Alt decimal number)

0047 3747 0077 ---- 7 Home
0048 3848 008D* ---- 8 Cursor Up
0049 3949 0084 ---- 9 Pg Up
2D4A 2D4A 008E* ---- Grey -
004B 344B 0073 ---- 4 Cursor Left
004C 354C 008F* ---- Numeric Keypad 5
004D 364D 0074 ---- 6 Cursor Right
2B4E 2B4E 0090* ---- Grey +
004F 314F 0075 ---- 1 End
0050 3250 0091* ---- 2 Cursor Down
0051 3351 0076 ---- 3 Pg Dn
0052 3052 0092* ---- 0 Ins
0053 2E53 0093* ---- . Del

10 June 1988 KEYS 3.10 Page 10

More than WE ever wanted to know about keyboards

Interrupt 16H ASCII/Scan Codes Expected by KEYS310

Norm Shft Ctrl Alt Keytop Unshifted Shifted
==== ==== ==== ==== ====== ============= =================

Extended Keys

System Request (Scan Code 54) (Int 09H Interpretation)

E047 E047 E077 0097* Home
E048 E048 E08D* 0098* Cursor Up
E049 E049 E084 0099* Page Up
E04B E04B E073 009B* Cursor Left
E04D E04D E074 009D* Cursor Right
E04F E04F E075 009F* End
E050 E050 E091* 00A0* Cursor Down
E051 E051 E076 00A1* Page Down
E052 E052 E092* 00A2* Insert
E053 E053 E093* 00A3* Delete
0085 0087 0089 008B F11
0086 0088 008A 008C F12
2A37* 2A37* 0096* 0037* Grey *
2FE0* 2FE0* 0095* 00A4* Grey /
0DE0 0DE0 0AE0 00A6* Carriage Return [Enter]

* As Noted in the text Scan Codes 0x86 through 0xA6
are unique to the Dell Model 200 / Phoenix Bios
3.07 10

---- implies that this combination is not legal on any
machine tested to date

10 June 1988 KEYS 3.10 Page 11

 January 2, 2018  Add comments

Leave a Reply