pynput
pynput copied to clipboard
Numpad Return None
Hey Guys,
i have a problem, every digit from my Numpad returns None.
i found on this:
if hasattr(key, 'vk') and 96 <= key.vk <= 105: print('You entered a number from the numpad: ', key.char)
but it still return None.
You know how to fix this? Already a lot of thanks to you guys
Thank you for your report.
When you say that your numpad returns None, do you mean that key.char
is printed as None
? That is expected, as there is no character representation for those characters. Do you still get different values for key.vk
?
Hi, I have this same issue.
I'm not sure why this is expected. Shouldn't key.char
return '5' when pressing '5' on the numpad?
I've currently solved this by mapping key.vk
to the numeric representation on an application level, but I still maintain that this would better be handled on the level of pynput.
inputs = {
96: "0",
97: "1",
98: "2",
99: "3",
100: "4",
101: "5",
102: "6",
103: "7",
104: "8",
105: "9",
}
if hasattr(key, 'vk') and 96 <= key.vk <= 105:
logger.debug(f'The keypad was pressed: {inputs[key.vk]}')
key_buffer += inputs[key.vk]