pydirectinput icon indicating copy to clipboard operation
pydirectinput copied to clipboard

keyDown/Up not working for Page Up/Down

Open andrewfstratton opened this issue 4 years ago • 1 comments

With windows applications, e.g. Google Chrome, if I use

pydirectinput.keyDown("pageup")

(and also keyUp) then the actual typed key is '3' (or '9' for pagedown), i.e. the extended scan code (?) attribute seem to be ignored. Briefly scanning how cursor keys are handled, there seems to be a need for similar checking for extended keycodes.

Note: I tested this also with cursor up/down and they work fine.

I't possible that other extended keys don't work as well.

andrewfstratton avatar Oct 18 '21 13:10 andrewfstratton

Yes, I’m experiencing the same issue. I tried remapping the keys in the same way it’s done for the Arrow Keys (e.g. 'right': MapVirtualKey(0x27, MAPVK_VK_TO_VSC)), but unfortunately, that didn’t work. I believe the problem lies in the key press triggering the numpad keys (e.g., 3 = Down, 9 = Up). When NumLock is turned off, it performs the Page Up/Down actions correctly. However, the numpad version of Page Up/Down doesn’t work for my application.

In my case, Minecraft only listens to the Page Up/Down keys from the Navigation Key Block for changing pages on a lectern. Unfortunately, this means the numpad version is unusable for my purposes.

I’d love to contribute a PR to fix this, but I’ve run out of ideas on how to resolve it.

Here’s a list of scan codes I found and tested: https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input#keystroke-message-flags https://docs.google.com/spreadsheets/d/1GSj0gKDxyWAecB3SIyEZ2ssPETZkkxn67gdIwL1zFUs/edit?gid=0#gid=0

juliuswms avatar Dec 27 '24 00:12 juliuswms