I'm trying to get the keyboard code of a character pressed in python. For this, I need to see if a keypad number is pressed.
This is not what I'm looking for:
import tty, sys
tty.setcbreak(sys.stdin)
def main():
tty.setcbreak(sys.stdin)
while True:
c = ord(sys.stdin.read(1))
if c == ord('q'):
break
if c:
print c
which outputs the ascii code of the character. this means, i get the same ord for a keypad 1 as as a normal 1.
I've also tried a similar setup using the curses library and raw, with the same results.
I'm trying to get the raw keyboard code. How does one do this?