Comments (12)
Ideally 'num 5' should only trigger with num pad 5 key, but it's working at the moment. As a workaround you can use the raw scan code, or 'hook'ing a Händler and checking the' is_keypad' attribute for every event.
from keyboard.
It's on the roadmap for sure, but I still have to publish the new suppression system and implement the xlib backend for linux. I'll give it a try between tasks, in case it's easier than it sounds.
Sorry, I work on this project on my free time with absolutely no remuneration, so I can't promise any dates.
from keyboard.
The library just takes the scan codes as reported by the OS. If the OS reports two keys as having the same scan code there's no way to differentiate between them. When the OS reports correctly you can see if the key is on the keypad or not by checking the event.is_keypad
attribute. Sorry, but I see no alternative if the OS is misreporting.
Num lock, scroll lock and caps lock are not treated differently from other keys. What you can do is listen for their key press events and update some internal variable with the current (imagined) state. I'm still researching on how to get the current state of those keys.
from keyboard.
I am currently using amd64 Python35 Win10. Keyboard is definitely marking the middle keys (insert, home, etc.) as numbers. I will investigate this further but may not be able to resolve this issue because I am not familiar with the underlying c infrastructure.
from keyboard.
I'm still researching on how to get the current state of those keys.
This can be done using GetKeyState with VK_CAPITAL, VK_NUMLOCK and VK_SCROLL. The least significant bit is set if they are toggled on.
>>> GetKeyState(VK_CAPITAL) & 1 #caps lock currently off
0
>>> GetKeyState(VK_CAPITAL) & 1 #caps lock currently on
1
Windows-only, however.
from keyboard.
Thank you @clugg, that will be extremely helpful. I'll be implemented it as soon as possible.
@xoviat, I just updated the Windows scan-code-table-building function to prefer non-keypad names when possible, please give release 0.9.5 a try. Unfortunately Windows gives no indication if a key was pressed as keypad or not (same scan code, same name, same virtual code, same flags).
Maybe checking for num lock status with @clugg's solution may help. I'll check later.
from keyboard.
It appears that the scan code is not enough information to distinguish whether the number pad keys are being pressed. The virtual key code is required to determine specifically the difference between the middle keys and the number keys.
There are several options here and I am willing to contribute. The best option (I think) would probably be to modify the scan code immediately within the queue processor if the vk code determines that the number keys are being pressed. Preferably, they should be modified to be the same scan codes as those that would be on a linux/mac machine for the number pad if possible.
Also, this project is looking kind of dead at this point (which is why I am using keyboard), but it does have some useful code for closing this issue.
from keyboard.
Good news everyone! Since version 0.9.6 the is_keypad
attribute and keypad names should be much more accurate. Those keys continue having the same scan code, which makes sense.
This patch required some manual hacking, and there seems to be a bug on Windows (extended&1
flag inverted in most keys but not all), but it's working.
If any of you still experience problems feel free to reopen the issue.
from keyboard.
How can I register a hotkey to num pad number that doesn't activate when pressing the number regularly?
from keyboard.
Can I expect an update that will fix this undesired behavior anytime soon?
from keyboard.
I discovered a difference in behavior between the current master branch and the latest release (Win10):
- Latest release: When hooking the key "1" the callback is triggered, when pressing "1" or "num 1", but not when pressing "delete".
- currrent master branch: When hooking the key "1" the callback is triggered, when pressing "1", "num 1" or "delete".
Whereas in both versions hooking the raw scan code of "num 1" would trigger "delete" and "num 1". It seems that this older version (latest release) could distinguish between "num 1" and "delete".
If it wasn't for hooking "delete" when hooking "1" I would have had a fix to my problem - this fix currently lead to "num 1" only hooking "num 1", but "1" hooking "1" and "delete".
from keyboard.
The solution has to be not to use the raw scan code for hooking but the combination of scan code and is_keypad flag.
from keyboard.
Related Issues (20)
- suppress=True breaks Windows Start Menu HOT 3
- Key name '~' in not mapped to any known key
- 'right alt' and 'left alt' parsable hotkeys behaves the same as the 'alt' parsable hotkey on Windows
- suppress=True doesn't work with read_hotkey and on_release_key HOT 1
- How to stop `Keyboard.hook` hooking `keyboard.send` or `keyboard.write`?
- Alt Down not detected with Streamdeck
- Returns upper and lower cases on Windows but only lower cases on Linux
- An OSError when the device is unplugged on RaspberrypiOS HOT 2
- Suddenly not working in mac os
- Periodicaly produce a TypeError: object of type 'NoneType' has no len()
- Cannot hold a key
- 'LMB + Ctrl' mulfunctions when `suppress = True`
- German and English Keyboard. Mixed letters (Z<-->Y)
- audio being muted when pressing "D" with this module HOT 1
- Can hotKey support double-clicking key like 'ctrl+ctrl'?
- calling keyboard.send() with a scan code produces wrong output
- Support language while in running
- Is Just Pressed
- suppress=True will cause a 1-second delay when pressing Ctrl, ALT, and other keys separately, such as running the ALT key in games
- Causes stutter / lag in game (Starcraft 2) when keys are being pressed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keyboard.