How to receive the control key from the keyboard and do the corresponding processing.

xiaoxiao2021-03-06  25

Header file: BIOS. Hint Bioskey (int CMD)

CMD = 0 Returns a keyboard value, such as keyboard pressing, waiting. CMD = 1 Query the keyboard Press the 0- key Press, non-0- Nuts Press CMD = 2 Returns the status of the control key, the return value is saved in the low 8-bit SHIFT button to press B5 Open Scroll Lock B1 left SHIFT button Press B6 Opened NUM LOCKB3 CTRL button Press B7 Open Caps Lockb4 Alt Key Press B8 Open INSERT

Example:

The following is given an example about the Bioskey function in TC3.0, and reads a reading will be beneficial: #include #include #include

#define Right 0x01 # define left 0x02 # define ctrl 0x04 # define alt 0x08

INT main (void) {int key, modifier

/ * Function 1 Returns 0 Until a key ispessed * / while (bioskey (1) == 0);

/ * Function 0 returns the key "is waiting * / key = bioskey (0);

/ * USE Function 2 To Dermine if Shift Keys WERE Used * / Modifiers = Bioskey (2); if (Modifiers) {Printf ("["); IF (Modifiers & Right) Printf ("Right"); if (Modifiers & LEFT) PRINTF ("Left"); if (Modifiers & Ctrl) Printf ("Ctrl"); if (Modifiers & Alt) Printf ("alt"); Printf ("]");} / * Print Out The Character Read * / If (isalnum (key & 0xff)) Printf ("'% c' / n", key); Else Printf ("% # 02x / n", key); return 0;}

转载请注明原文地址:https://www.9cbs.com/read-65473.html

New Post(0)