pdg@ihdev.UUCP (P. D. Guthrie) (11/13/85)
I am posting the following for a friend so please do not reply, but rather send mail to: seismo!umcp-cs!cal-unix!ptseg Somewhere in the address-space of the IBM pc is a byte that indicates the current status of all the shift keys on the keyboard, including the normal-shifts, ctrl-key, scroll-lock, and num-lock keys. I need to know this address so our program can display a status line at the bottom of screen telling the user whether or not his num-lock caps-lock, etc are on.
broehl@watdcsu.UUCP (Bernie Roehl) (11/14/85)
In article <395@ihdev.UUCP> pdg@ihdev.UUCP (P. D. Guthrie) writes: > > Somewhere in the address-space of the IBM pc is a byte that indicates > the current status of all the shift keys on the keyboard, including > the normal-shifts, ctrl-key, scroll-lock, and num-lock keys. The best (i.e. most portable) way of doing this is to use the keyboard input routine in the rom (int 16h) to return the shift status byte: mov ah,2 ; function code for "return shift state" int 16h The result will be a byte in the AL register whose bits have the following meanings: INSERT | CAPS LOCK | NUM LOCK | SCROLL LOCK | ALT | CTRL | L. SHIFT | R. SHIFT INSERT means insert mode is active, the three LOCK keys mean that mode has been toggled (i.e. CAPS LOCK is ON), and the last four mean those keys are down at the time the call is made. In the original PC, this bye was stored at offset 17H in the ROM BIOS data segment (segaddr 40H). This may be different in different releases of the PC rom, it may be different in the XT, the AT and the JR, and will almost certainly be different in clones. You should therefore use method above rather than referring to the byte directly. (However, if you choose to, the byte at offset 18H has the following in it: INS DOWN | CAPS LOCK DOWN | NUM LOCK DOWN | SCROLL LOCK DOWN | HOLD | 0 | 0 | 0 Here, the bits all mean that the corresponding key is depressed. You could thus (if you really wanted to) use any of these keys as true "shift" keys. (This is probably not useful and almost certainly non-portable). Hope this helps; for more info, see the IBM technical reference manual.
bill@hp-pcd.UUCP (bill) (11/18/85)
The byte you're looking for is, I believe, at 0040:0017 (hex). Instead of directly reading this byte, however, you probably ought to consider using Int 16h function AH=2, which returns this very byte in AL. Int 16h functionality should be the same for PC, XT, AT, clones, etc; the exact RAM location used (if any) may move around. ... mov ah,2 int 16h ... Returns in AL the current shift status, with each bit defined as follows: INS_state = 80h ;Insert state is active CAPS_state = 40h ;Caps lock has been toggled NUM_state = 20h ;Num lock has been toggled SCROLL_state = 10h ;Scroll lock has been toggled ALT_shift = 08h ;ALT key is depressed CTL_shift = 04h ;CTRL key is depressed LEFT_shift = 02h ;Left SHIFT key is depressed RIGHT_shift = 01h ;Right SHIFT key is depressed bill frolik hp-pcd!bill
amb@duke.UUCP (A. Michael Berman) (11/19/85)
In article <1872@watdcsu.UUCP> broehl@watdcsu.UUCP (Bernie Roehl) writes: >In article <395@ihdev.UUCP> pdg@ihdev.UUCP (P. D. Guthrie) writes: >> >> Somewhere in the address-space of the IBM pc is a byte that indicates >> the current status of all the shift keys on the keyboard, including >> the normal-shifts, ctrl-key, scroll-lock, and num-lock keys. > ... > In the original PC, this bye was stored at >offset 17H in the ROM BIOS data segment (segaddr 40H). This may be different >in different releases of the PC rom, it may be different in the XT, the AT >and the JR, and will almost certainly be different in clones. In at least one clone (Heath/Zenith 150pc family) it is done in exactly the same way. In fact, virtually all the important bios memory locations are (and must) be the same. This is one distinction between a "true" or "near-clone" and a generic MS-DOS machine.