@node _bios_keybrd, bios @findex _bios_keybrd @subheading Syntax @example #include unsigned _bios_keybrd(unsigned cmd); @end example @subheading Description The @code{_bios_keybrd} function uses INT 0x16 to access the keyboard services. The @var{cmd} argument can be any of the following manifest constants: @table @code @item _KEYBRD_READ read the next key pressed. @item _NKEYBRD_READ read the next extended key pressed. Unlike @code{_KEYBRD_READ}, this command knows about keys introduced with the AT-style 101-key keyboards, such as @key{F11} and @key{F12}, and can distinguish between the editing keys on the numeric pad and the grey keys of the edit pad. On the other hand, some of the extended keys return two-byte sequences which typically begin with the @code{E0h} (224 decimal) prefix, so code that uses @code{_NKEYBRD_READ} should deal with this complexity. @item _KEYBRD_READY check if a key is waiting in the keyboard buffer. @item _NKEYBRD_READY check if an extended key is waiting in the keyboard buffer. Like @code{_KEYBRD_READY}, but recognizes extended keys such as @key{F12}, which @code{_KEYBRD_READY} ignores. @item _KEYBRD_SHIFTSTATUS read keyboard shift state (the byte at the address @code{40h:17h} in the BIOS data area): @example 7654 3210 Meaning ---- ---X Right SHIFT is pressed ---- --X- Left SHIFT is pressed ---- -X-- CTRL is pressed ---- X--- ALT is pressed ---X ---- Scroll Lock locked --X- ---- Num Lock locked -X-- ---- Caps Lock locked X--- ---- Insert locked @end example @item _NKEYBRD_SHIFTSTATUS read keyboard shift and extended shift state (the byte at the address @code{40h:17h} in the BIOS data area combined with the extended shift flags from the bytes at addresses @code{40h:18h} and @code{40h:96h}): @example FEDC BA98 7654 3210 Meaning ---- ---- ---- ---X Right SHIFT is pressed ---- ---- ---- --X- Left SHIFT is pressed ---- ---- ---- -X-- CTRL is pressed ---- ---- ---- X--- ALT is pressed ---- ---- ---X ---- Scroll Lock locked ---- ---- --X- ---- Num Lock locked ---- ---- -X-- ---- Caps Lock locked ---- ---- X--- ---- Insert locked ---- ---X ---- ---- Left CTRL is pressed ---- --X- ---- ---- Left ALT is pressed ---- -X-- ---- ---- Right CTRL is pressed ---- X--- ---- ---- Right ALT is pressed ---X ---- ---- ---- Scroll Lock is pressed --X- ---- ---- ---- Num Lock is pressed -X-- ---- ---- ---- Caps Lock is pressed X--- ---- ---- ---- SysReq is pressed @end example @end table Return Value With the @code{*_READ} and @code{*_SHIFTSTATUS} arguments, the @code{_bios_keybrd} function returns the contents of the @sc{ax} register after the BIOS call. For the @code{*_READ} arguments, this is the combination of scan code and ASCII code for alphanumeric keys, or a scan code and either zero or the @code{E0h} prefix for special keys. With the @code{*_READY} arguments, @code{_bios_keybrd} returns 0 if no key is waiting in the BIOS keyboard buffer. If there is a key, @code{_bios_keybrd} returns the key waiting to be read (that is, the same value as the corresponding @code{*_READ} would return). With the @code{*_READ} and @code{*_READY} arguments, the @code{_bios_keybrd} function returns -1 if @kbd{Ctrl+@key{BREAK}} has been pressed and is the next keystroke to be read. @subheading Portability @portability !ansi, !posix @subheading Example @example while( !_bios_keybrd(_KEYBRD_READY) ) try_to_do_something(); @end example