pynput icon indicating copy to clipboard operation
pynput copied to clipboard

Numpad Return None

Open Toolknight opened this issue 3 years ago • 3 comments

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

Toolknight avatar Mar 29 '21 18:03 Toolknight

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?

moses-palmer avatar Mar 29 '21 19:03 moses-palmer

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?

image

pieterhelsen avatar Dec 01 '21 14:12 pieterhelsen

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]

pieterhelsen avatar Dec 02 '21 09:12 pieterhelsen