[comp.sys.ibm.pc] Enhanced Keyboard Scan Codes

BP3@PSUVM.BITNET (Larry Belan) (01/13/89)

I was wondering if anyone has the scan codes produced by the IBM Enhanced
keyboard?  I have a list for the old PC keyboard but it dosen't help
with the extra cursor keys and the numeric keypad.

I'm using the codes to assemble a keyboard translation program and need
the codes to see which key has been hit.

Thanks in advance.
-------
  Lawrence (Larry) Belan ][                         75745,242 (CompuServe)
  Computer Lab Technician/Telecommnnications Aide     L.BELAN (GEnie)
  The Pennsylvania State University               bp3 @ psuvm (bitnet)
  The Fayette Campus             ...!psuvax1!psuvm.bitnet!bp3 (uucp)
  Computer Center
  Box 519, Rt. 119 North
  Uniontown, PA 15401

  (412) 430-4163

jerry@starfish.Convergent.COM (Gerald Hawkins) (01/14/89)

From article <67172BP3@PSUVM>, by BP3@PSUVM.BITNET (Larry Belan):
> I was wondering if anyone has the scan codes produced by the IBM Enhanced
> keyboard?  I have a list for the old PC keyboard but it dosen't help
> with the extra cursor keys and the numeric keypad.
>   Lawrence (Larry) Belan ][                         75745,242 (CompuServe)
>   The Fayette Campus             ...!psuvax1!psuvm.bitnet!bp3 (uucp)
-
-
The book _DOS Programmer's Reference_ (Que books) page 149 has an AT
advanced keyboard scan code map and a regular PC keyboard map.

What I wonder is why programs designed to read scan codes (SHOWKEYS for
example) do not return a value for F11 and F12.  Sometime I'll have to
investigate.


Rainy Days and
Automatic Weapons Fire
Alway Get Me Down.

These opinions are mine.
Jerry.  (jerry@starfish.convergent.COM)
-----

Ralf.Brown@B.GP.CS.CMU.EDU (01/14/89)

In article <914@starfish.Convergent.COM>, jerry@starfish.Convergent.COM (Gerald Hawkins) writes:
}What I wonder is why programs designed to read scan codes (SHOWKEYS for
}example) do not return a value for F11 and F12.  Sometime I'll have to
}investigate.

Because you have to use INT 16h/AH=10h,11h,12h to read the new keys.  The old
calls with AH=00h,01h,02h *throw*out* the new keystrokes.
--
UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=-=-=- Voice: (412) 268-3053 (school)
ARPA: ralf@cs.cmu.edu  BIT: ralf%cs.cmu.edu@CMUCCVMA  FIDO: Ralf Brown 1:129/31
			Disclaimer? I claimed something?
	You cannot achieve the impossible without attempting the absurd.

prc@maxim.ERBE.SE (Robert Claeson) (01/17/89)

In article <23cf3ecd@ralf>, Ralf.Brown@B.GP.CS.CMU.EDU writes:
> In article <914@starfish.Convergent.COM>, jerry@starfish.Convergent.COM (Gerald Hawkins) writes:

> }What I wonder is why programs designed to read scan codes (SHOWKEYS for
> }example) do not return a value for F11 and F12.  Sometime I'll have to
> }investigate.

> Because you have to use INT 16h/AH=10h,11h,12h to read the new keys.  The old
> calls with AH=00h,01h,02h *throw*out* the new keystrokes.

What happens when I use these calls with an old keyboard?
-- 
Robert Claeson, ERBE DATA AB, P.O. Box 77, S-175 22 Jarfalla, Sweden
"No problems." -- Alf
Tel: +46 758-202 50  EUnet:    rclaeson@ERBE.SE  uucp:   uunet!erbe.se!rclaeson
Fax: +46 758-197 20  Internet: rclaeson@ERBE.SE  BITNET: rclaeson@ERBE.SE

mitch@arcturus.UUCP (Mitchell S. Gorman) (01/18/89)

In article <67172BP3@PSUVM>, BP3@PSUVM.BITNET (Larry Belan) writes:
> I was wondering if anyone has the scan codes produced by the IBM Enhanced
> keyboard?  I have a list for the old PC keyboard but it dosen't help
> with the extra cursor keys and the numeric keypad.



Yeah, I'd also like to know what they are.  I have a little program I 
wrote so that I wouldn't have to keep referring to documentation (pgm.
is based on INT $16, forgive me if I gave the wrong number), but it
just plain refuses to acknowledge F11, F12, and the SysReq keys.

I'm writing some software for a FlexCache 20/386, for some INexpert 
users, and I'd really like to be able to pick up those keystrokes.
Otherwise, I just know I'll get too many support calls ("How do I hit
a control F4, and what is F4 anyway???"  :^)


Any assistance may or may not be appreciated, depending on the stock
market.

Mitch @ Rockwell, Anaheim

leonard@bucket.UUCP (Leonard Erickson) (01/18/89)

In article <914@starfish.Convergent.COM> jerry@starfish.Convergent.COM (Gerald Hawkins) writes:
<From article <67172BP3@PSUVM>, by BP3@PSUVM.BITNET (Larry Belan):
<> I was wondering if anyone has the scan codes produced by the IBM Enhanced
<> keyboard?  I have a list for the old PC keyboard but it dosen't help
<> with the extra cursor keys and the numeric keypad.
<>   Lawrence (Larry) Belan ][                         75745,242 (CompuServe)
<>   The Fayette Campus             ...!psuvax1!psuvm.bitnet!bp3 (uucp)
<-
<-
<The book _DOS Programmer's Reference_ (Que books) page 149 has an AT
<advanced keyboard scan code map and a regular PC keyboard map.
<
<What I wonder is why programs designed to read scan codes (SHOWKEYS for
<example) do not return a value for F11 and F12.  Sometime I'll have to
<investigate.

They call the BIOS function for the old keyboard. There is a *different*
one for getting the enhanced info (though it returns the same results
for the "old" keys). I think it also uses E0h instead of 00h as the first
byte of the code. <sigh>

Check the Interrupt list for exact details...
-- 
Leonard Erickson		...!tektronix!reed!percival!bucket!leonard
CIS: [70465,203]
"I used to be a hacker. Now I'm a 'microcomputer specialist'.
You know... I'd rather be a hacker."

BP3@PSUVM.BITNET (Larry Belan) (01/19/89)

Since Mitch was unable to post this...I will do it for him.


Received: from CORNELLA.BITNET by PSUVM.BITNET (Mailer X1.25) with BSMTP id
 7758; Wed, 18 Jan 89 15:35:19 EST
Received: by CORNELLA (Mailer R2.01) id 6621; Wed, 18 Jan 89 15:37:46 EST
Date:         Wed, 18 Jan 89 15:31:46 EST
From:         Rich Kennerly <LVL@CORNELLA>
Subject:      enhanced keyboards
To:           Larry Belan <bp3@psuvm.bitnet>
cc:           Mitchell S Gorman <mitch@arcturus.uucp>

Larry, Mitch,

   Here is a list of the extra keys on an enhanced keyboard:

Enhanced Keyboard key:                  BIOS value:
                                        base    shift   cntrl   alt
F11                                     8500    8700    8900    8b00
F12                                     8600    8800    8A00    8C00
kp-Enter                                E00D    E00D    E00D    A600
KP-/                                    E02F    E02F    9500    A400
KP-*                                    372A    372A    9600    3700

HOME                                    47E0    47E0    77E0    9700
UP ARROW                                48E0    48E0    8DE0    9800
PAGE UP                                 49E0    49E0    84E0    9900
LEFT ARROW                              4BE0    4BE0    73E0    9B00
RIGHT ARROW                             4DE0    4DE0    74E0    9D00
END                                     4FE0    4FE0    75E0    9F00
DOWN ARROW                              50E0    50E0    91E0    A000
PAGE DOWN                               51E0    51E0    76E0    A100
INSERT                                  52E0    52E0    92E0    A200
DELETE                                  53E0    53E0    93E0    A300

Note that you cannot get these values with the old BIOS interrupt,
it will remove the E0's to be compatible with the old keyboard.  See
the following code fragments that use the old and new BIOS calls.


getkey_     PROC   NEAR         ; get key code for standard keyboard
            mov    ah,01H
            int    16h
            jnz    GOTAKEY
            mov    ax,00H
            ret
GOTAKEY:
            mov    ah,00H
            int    16h
            ret
getkey_     ENDP

getxkey_    PROC   NEAR         ; get key code for enhanced keyboard
            mov    ah,11H
            int    16h
            jnz    GOTXKEY
            mov    ax,0
            ret
GOTXKEY:
            mov    ah,10H
            int    16h
            ret
getxkey_    ENDP

I have found that an AT with old keyboard and old BIOS (you need the
new BIOS to fully appreciate the enhanced keyboard) will get very
upset if you try to use the new BIOS function calls with it.  Here
is a routine that will look into the BIOS data area to see if BIOS
found an enhanced keyboard at INIT time.  Note that this approach is
not ideal since IBM and others can change the layout of BIOS at
will; fortunately they never seem to.  In any case there is no
interrupt call that will tell you this (if there is let me know
please).

; gkybdtype returns 0 for standard 84 key kybd, 10H for enhanced keyboard

        KB_FLAG_3       equ 096H        ; address of keyboard flag byte
        KBX             equ 00010000B   ; enhanced keyboard flag bit

gkybdtype_      proc near
        push    es
        mov     ax,40H
        mov     es, ax
        mov     ax,es:[KB_FLAG_3]
        and     ax,KBX
        pop     es
        ret
gkybdtype_      endp

    Do either of you know the userid/node that I should send letters for
this newsgroup (ibm.pc)?  Our local machine does not forward to the entire
net.  If not feel free to forward this.

RICH KENNERLY - LVL@CORNELLA.CIT.CORNELL.EDU
CIT - Network Development
125 Caldwell Hall
607-255-7342

mitch@arcturus.UUCP (Mitchell S. Gorman) (01/24/89)

In article <68082BP3@PSUVM>, BP3@PSUVM.BITNET (Larry Belan) writes:
> Since Mitch was unable to post this...I will do it for him.
> 
>	[extended keyboard code stuff deleted] 


If this was mailed to me, I never got it, which is, of course, the
reason why I haven't posted it.  Sorry 'bout that!

Thanks for putting it out, though, it'll come in handy!

Mitch @ Rockwell, Anaheim


Disclaimer:	There is no dark side of the moon, really;  as a matter
		of fact it's all dark.

orn@rsp.is (Orn E. Hansen) (01/25/89)

Ok, here comes data that should supply you with what you need.  I send it
to you in a format that can be put directly into a header file.  After
all thats where it came from anyway.  At the bottom you'll find a way
to find out what kind of keyboard is attached to your system.  If you
need any further info, feel free to mail.

+-----------------------------------+------------------------------------+
| Orn Hansen                        |                                    |
| System analyst                    | May the source be with you.        |
+-----------------------------------+------------------------------------+


#define CHR_ALT_ESC             0x01

/* Items 0x02 through 0x0D are unclaimed. */

#define CHR_ALT_BS              0x0E
#define CHR_SHIFT_TAB           0x0f

#define CHR_ALT_Q               0x10
#define CHR_ALT_W               0x11
#define CHR_ALT_E               0x12
#define CHR_ALT_R               0x13
#define CHR_ALT_T               0x14
#define CHR_ALT_Y               0x15
#define CHR_ALT_U               0x16
#define CHR_ALT_I               0x17
#define CHR_ALT_O               0x18
#define CHR_ALT_P               0x19
#define CHR_ALT_OBRK            0x1A
#define CHR_ALT_CBRK            0x1B
#define CHR_ALT_ENTER           0x1C

/* Item 0x1d is unclaimed. */

#define CHR_ALT_A               0x1e
#define CHR_ALT_S               0x1f
#define CHR_ALT_D               0x20
#define CHR_ALT_F               0x21
#define CHR_ALT_G               0x22
#define CHR_ALT_H               0x23
#define CHR_ALT_J               0x24
#define CHR_ALT_K               0x25
#define CHR_ALT_L               0x26
#define CHR_ALT_SEMI            0x27
#define CHR_ALT_QUOTE           0x28
#define CHR_ALT_BQUOTE          0x29

/* Item 0x2a is unclaimed. */
#define CHR_ALT_BSLSH           0x2B

#define CHR_ALT_Z               0x2c
#define CHR_ALT_X               0x2d
#define CHR_ALT_C               0x2e
#define CHR_ALT_V               0x2f
#define CHR_ALT_B               0x30
#define CHR_ALT_N               0x31
#define CHR_ALT_M               0x32
#define CHR_ALT_COMMA           0x33
#define CHR_ALT_PERIOD          0x34
#define CHR_ALT_SLSH            0x35
#define CHR_N_ALT_STAR          0x37

/* Items 0x37 through 0x3a are unclaimed. */

#define CHR_F1                  0x3b
#define CHR_F2                  0x3c
#define CHR_F3                  0x3d
#define CHR_F4                  0x3e
#define CHR_F5                  0x3f
#define CHR_F6                  0x40
#define CHR_F7                  0x41
#define CHR_F8                  0x42
#define CHR_F9                  0x43
#define CHR_F10                 0x44

/* Items 0x45 through 0x46 are unclaimed. */

#define CHR_HOME                0x47
#define CHR_UP                  0x48
#define CHR_PGUP                0x49
#define CHR_N_ALT_DASH          0x4A
#define CHR_LEFT                0x4b
#define CHR_N_5                 0x4C
#define CHR_RIGHT               0x4d
#define CHR_N_ALT_PLUS          0x4E
#define CHR_END                 0x4f
#define CHR_DOWN                0x50
#define CHR_PGDN                0x51
#define CHR_INS                 0x52
#define CHR_DEL                 0x53

#define CHR_SHIFT_F1            0x54
#define CHR_SHIFT_F2            0x55
#define CHR_SHIFT_F3            0x56
#define CHR_SHIFT_F4            0x57
#define CHR_SHIFT_F5            0x58
#define CHR_SHIFT_F6            0x59
#define CHR_SHIFT_F7            0x5a
#define CHR_SHIFT_F8            0x5b
#define CHR_SHIFT_F9            0x5c
#define CHR_SHIFT_F10           0x5d

#define CHR_CONTROL_F1          0x5e
#define CHR_CONTROL_F2          0x5f
#define CHR_CONTROL_F3          0x60
#define CHR_CONTROL_F4          0x61
#define CHR_CONTROL_F5          0x62
#define CHR_CONTROL_F6          0x63
#define CHR_CONTROL_F7          0x64
#define CHR_CONTROL_F8          0x65
#define CHR_CONTROL_F9          0x66
#define CHR_CONTROL_F10         0x67

#define CHR_ALT_F1              0x68
#define CHR_ALT_F2              0x69
#define CHR_ALT_F3              0x6a
#define CHR_ALT_F4              0x6b
#define CHR_ALT_F5              0x6c
#define CHR_ALT_F6              0x6d
#define CHR_ALT_F7              0x6e
#define CHR_ALT_F8              0x6f
#define CHR_ALT_F9              0x70
#define CHR_ALT_F10             0x71

/* Item 0x72 is unclaimed. */

#define CHR_CONTRL_LEFT         0x73
#define CHR_CONTRL_RIGHT        0x74
#define CHR_CONTRL_END          0x75
#define CHR_CONTRL_PGDN         0x76
#define CHR_CONTRL_HOME         0x77

#define CHR_ALT_1               0x78
#define CHR_ALT_2               0x79
#define CHR_ALT_3               0x7a
#define CHR_ALT_4               0x7b
#define CHR_ALT_5               0x7c
#define CHR_ALT_6               0x7d
#define CHR_ALT_7               0x7e
#define CHR_ALT_8               0x7f
#define CHR_ALT_9               0x80
#define CHR_ALT_0               0x81
#define CHR_ALT_DASH            0x82
#define CHR_ALT_EQU             0x83

#define CHR_CONTRL_PGUP         0x84
#define CHR_F11                 0x85
#define CHR_F12                 0x86
#define CHR_SHIFT_F11           0x87
#define CHR_SHIFT_F12           0x88
#define CHR_CONTRL_F11          0x89
#define CHR_CONTRL_F12          0x8A
#define CHR_ALT_F11             0x8b
#define CHR_ALT_F12             0x8c
#define CHR_N_CONTRL_UP         0x8d
#define CHR_N_CONTRL_DASH       0x8e
#define CHR_N_CONTRL_5          0x8f
#define CHR_N_CONTRL_PLUS       0x90
#define CHR_N_CONTRL_DOWN       0x91
#define CHR_N_CONTRL_INSERT     0x92
#define CHR_N_CONTRL_DEL        0x93
#define CHR_CONTRL_TAB          0x94
#define CHR_N_CONTRL_SLSH       0x95
#define CHR_N_CONTRL_STAR       0x96
#define CHR_C_ALT_HOME          0x97
#define CHR_C_ALT_UP            0x98
#define CHR_C_ALT_PGUP          0x99
#define CHR_C_ALT_LEFT          0x9b
#define CHR_C_ALT_RIGHT         0x9d
#define CHR_C_ALT_END           0x9f
#define CHR_C_ALT_DOWN          0xa0
#define CHR_C_ALT_PGDN          0xa1
#define CHR_C_ALT_INSERT        0xa2
#define CHR_C_ALT_DEL           0xa3
#define CHR_N_ALT_SLSH          0xa4
#define CHR_ALT_TAB             0xa5
#define CHR_N_ALT_ENTER         0xa6

#define CHR_N_STAR              0xad
#define CHR_N_DASH              0xae
#define CHR_N_PLUS              0xaf

#define CHR_N_ENTER             0xb0
#define CHR_N_CONTRL_ENTER      0xb1
#define CHR_N_SLSH              0xb2
#define CHR_C_HOME              0xb3
#define CHR_C_UP                0xb4
#define CHR_C_PGUP              0xb5
#define CHR_C_LEFT              0xb6
#define CHR_C_RIGHT             0xb7
#define CHR_C_END               0xb8
#define CHR_C_DOWN              0xb9
#define CHR_C_PGDN              0xba
#define CHR_C_INSERT            0xbb
#define CHR_C_DEL               0xbc
#define CHR_C_CONTRL_LEFT       0xbd
#define CHR_C_CONTRL_RIGHT      0xbe
#define CHR_C_CONTRL_END        0xbf
#define CHR_C_CONTRL_PGDN       0xc0
#define CHR_C_CONTRL_HOME       0xc1
#define CHR_C_CONTRL_PGUP       0xc2
#define CHR_C_CONTRL_UP         0xc3
#define CHR_C_CONTRL_DOWN       0xc4
#define CHR_C_CONTRL_INSERT     0xc5
#define CHR_C_CONTRL_DEL        0xc6


#define CHR_LAST_EXT            0xC6      /* Last extended key code */


/* Codes that identify the keyboard type connected */

#define 	_KBD_102		4
#define 	_KBD_101		3
#define 	_KBD_84			2
#define 	_KBD_83			1

#define		KBD_WAIT		1
#define		KBD_NOWAIT		0

#define         KBD_TYPE()              ( _kbd_flags & 0x03 )
#define         KBD_E_BIOS()            ( _kbd_flags & 0x08 )

extern int _kbd_flags;

orn@rsp.is (Orn E. Hansen) (01/25/89)

Some machines have a BIOS that can support Enhanced keyboards while others
don't.  Some keys need a little further translation than just the scan
codes,  there is a magic scan code 0x??e0 that is to identify these
keycodes that are not on the PC-Kbd.

There is also a specific way to find out weather the computer has BIOS,
DOS etc., that supports the E-Kbd.  The BIOS date on the XT is supposed
to be after 01-01-86 and for the AT 11-01-86 (mm-dd-yy).

Ok, heres some info on the magic codes 0x??e0.  You take the high byte
subtract it with 0x47 and add 0xb3 to get the actual (correct codes).
Also, the following codes need some special handling:

0x372a -> 0xad00
0x4a2d -> 0xae00
0x4e2b -> 0xaf00
0xe00d -> 0xb000
0xe00a -> 0xb100
0xe02f -> 0xb200

You'll need to re-program the int16 routine (the 0 and 1 functions)
to translate these codes and beware DOS throw's away scan codes it
doesn't recognise!

The keyboard types are stored at location 0x40:0x96, the info on
bits are stored in the header file.  The date of the BIOS is stored
at location 0xFFFF:5 in the format "mm/dd/yy" absolutely.


==========================================================================
Orn Hansen
System analyst.
--------------------------------------------------------------------------