Reading Extended Keyboard Characters with CLast reviewed: July 17, 1997Article ID: Q43007 |
6.00 6.00a 6.00ax 7.00 | 1.00 1.50
MS-DOS | WINDOWSkbprg
The information in this article applies to:
SUMMARYThe _bios_keybrd() function uses INT function 16H to access the keyboard services. The C 5.1 _bios_keybrd function() is based on the original PC BIOS INT 16H, which does not support the extended keyboard. The BIOS for AT's and PS/2's has been updated to support the extended keyboard. The updated BIOS has three addition services: 10H reads a character from the extended keyboard, 11H gets the extended-keyboard status, 12H gets the extended-keyboard flags. To allow the C 5.1 _bios_keybrd() to use these updated keyboard services, define the following manifest constants.
#define _NKEYBRD_READ 0x10 /* read extended chars */ #define _NKEYBRD_READY 0x11 /* check if key waiting */ #define _NKEYBRD_SHIFT_STATUS 0x12 /* check shift key status */To read keys from the extended keyboard, use these new constants in place of the manifest constants described on page 138 of the "Microsoft C for the MS-DOS Operating System: Run-Time Library Reference" for version 5.1. These constants are already defined in C versions 6.0 and later.
MORE INFORMATIONThe following program uses the enhanced services of INT function 16H to determine if the UP ARROW or DOWN ARROW keys on the extended keyboard were pressed. Uncomment the #define for C 5.1 and earlier.
Sample Code:
/* Compile options needed: none */ /* #define _NKEYBRD_READ 0x10 */ #include <bios.h> #include <stdio.h> void main(){ unsigned key; key = _bios_keybrd( _NKEYBRD_READ ); if ( key == 0x48e0 ) printf( "Up arrow was pressed.\n" ); else if ( key == 0x50e0 ) printf( "Down arrow was pressed.\n" ); else printf( "Neither the up or the down arrow was pressed.\n" );}
|
Additional reference words: kbinf 6.00 6.00a 6.00ax 7.00 1.00 1.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |