moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.79k stars 248 forks source link

5 on keypad not working, 5 above letters on keyboard works fine #418

Open kurt-rhee opened 2 years ago

kurt-rhee commented 2 years ago

Description I've noticed that if i press the number 5 on my keypad it reads in as null whereas if i press 5 on the numbers above the letters on my keyboard then it works fine.

Platform and pynput version Ubuntu 20.04, pynput 1.7.4

To Reproduce ` class Scanner: def init(self):

Collect events until released

    self.keys = []

def on_press(self, key):
    if key == keyboard.Key.esc:
        return False  # stop listener
    else:
        try:
            print(key.char)
            self.keys.append(key.char)
        except AttributeError:
            print(key)
            self.keys.append(key.char)

@staticmethod
def on_release(key):
    pass

scanner = Scanner()
with keyboard.Listener(
        on_press=scanner.on_press,
        on_release=scanner.on_release) as listener:
    listener.join()
st.write(scanner.keys)

`

image

moses-palmer commented 2 years ago

Thank you for your report.

I have made a small change to the way the virtual key code is calculated for keypad keys, and it works on my system. The fix is in the branch fixup-xorg-keypad-5. Is it possible for you to test it?

duncathan commented 2 years ago

Just wanted to report in that I've tested the change in that branch locally, and it fixes the issue on my system as well. Would be incredibly helpful to see this fix in a proper release so that I can stay synced in the future! The issue here would otherwise be blocking my current project.