Function prototype: int bioskey (int cmd)
Description: The function prototype of bioskey () is in the BIOS. h.
Bioskey () completes the direct keyboard operation, and the value of cmd determines what operation to perform.
cmd = 0:
When cmd is 0, bioskey () returns the next value typed on the keyboard (it will wait until a key is pressed). It returns a binary number of 16 bits, including two different values. When a common key is pressed, its lower 8 bits store the ASCII code of the character; For special keys (such as direction keys, F 1 ~ F 12, etc. ), the lower 8 bits are 0, and the upper 8 bytes store the scan code of the key.
cmd = 1:
When cmd is 1, bioskey () queries whether a key has been pressed, and returns a non-zero value if a key has been pressed, otherwise returns 0.
cmd = 2:
When cmd is 2, bioskey () returns the states of Shift, Ctrl, Alt, ScrollLock, NumLock, CapsLock and Insert keys. The state of each key is stored in the lower 8-bit byte of the return value.
Byte bit meaning
0 move right key state
1 left shift key status
3 Ctrl key state
4 Alt key state
5 ScrollLock key status
6 NumLock key state
7 CapsLock key status
8 Insert key status
The arrow keys can use the following procedures!
#define Key_Up 0x4800/*up*/
#define Key_Down 0x5000/*down*/
# define Key _ Right 0x4d 00/* Right */
#define Key_Left 0x4b00/*left*/
int key = BIOS key(0);
Switch (key)
{
case Key_Up:/*code*/
case Key_Down:/*code*/
case Key_Left:/*code*/
case Key_Right:/*code*/
}