t2:key_check

key_check


key_check — Retrieve code of a pressed key

Description


uint8 key_check();

Retrieve the code of the keyboard key that is currently being pressed, or return zero if no key is being pressed.

Return Value


Code of the key that are being pressed.

If more than one key is being pressed, only the code of the first one is returned.

Examples


Example #1 key_check() example

#include <keyboard.gph>
 
main {
    // Output the key code of pressed keys
    output_keycode();
}
 
void output_keycode() {
    static uint8 previous_keycode;
    uint8 keycode;
 
    keycode = key_check();
    if(keycode != previous_keycode) {
        if(keycode) {
            printf("Key Code: %02X", keycode);
        }
        previous_keycode = keycode;
    }
    return;
}

See Also

t2/key_check.txt · Last modified: 2018/02/20 07:01 by J2Kbr