kb_sm.get - Kyuchumimo/Micro-Joy-Home-Video-Computer GitHub Wiki

đŸ§ŠđŸ•šī¸ This is a general-purpose input-related function.

kb_sm.get() -> scancode

Description

This function is different from others. It is used to return scancodes from an PC-AT / PS/2 keyboard. When called, it will interrupt everything until a key is pressed. Because of this, this function is only suitable for Turn-Based games.

You can use interrupts, a new thread or a Programmable I/O to perform another task while this function is busy waiting for a key press or key release.

Example

while True:
    # kb_sm.get() waits for a value in the rx queue and returns it
    # The shift and and discard the start, parity and stop bits and align the scan code to the right
    key = (kb_sm.get() >> 22) & 0xFF
    print ('Key = {:02X}'.format(key))