Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
GetShift
◄Example► ◄Back► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
;* GetShift - Gets current shift status. Checks for extended keyboard,
;* and if available returns additional shift information.
;*
;* Shows: BIOS Interrupt - 16h, Functions 2 and 12h (Get Keyboard Flags)
;*
;* Params: None
;*
;* Return: Long integer
;* high word = 0 for non-extended keyboard
;* 1 for extended keyboard
;* low word has following bits set when indicated keys are pressed:
;* 0 - Right shift 8 - Left Ctrl
;* 1 - Left shift 9 - Left Alt
;* 2 - Ctrl 10 - Right Ctrl
;* 3 - Alt 11 - Right Alt
;* 4 - Scroll Lock active 12 - Scroll Lock pressed
;* 5 - Num Lock active 13 - Num Lock pressed
;* 6 - Caps Lock active 14 - Caps Lock pressed
;* 7 - Insert toggled 15 - Sys Req pressed
GetShift PROC
sub dx, dx ; Assume non-extended keyboard
mov ah, 2 ; and use Function 2
mov es, dx ; Point ES to low memory
test BYTE PTR es:[496h], 16 ; Extended keyboard installed?
jz @F ; No? Leave AH as Function 2
inc dx ; Yes? Set high word of return code
mov ah, 12h ; and use Function 12h
@@: int 16h ; Get Shift Status
ret
GetShift ENDP
-♦-