Can't map some keys
See original GitHub issueHi, thanks for this library, I’m trying to make use of it to create a simple custom hotkey “alias”. I’m on a MacBook Air running Linux (Gentoo).
import keyboard
import time
keyboard.clear_all_hotkeys()
keyboard.add_hotkey('win+c', lambda: keyboard.send('ctrl+c'))
keyboard.add_hotkey('win+v', lambda: keyboard.send('ctrl+v'))
keyboard.add_hotkey('win+l', lambda: keyboard.send('ctrl+l'))
keyboard.add_hotkey('win+e', lambda: keyboard.send('ctrl+l'))
while True:
time.sleep(10)
On the script above, win+l
and win+e
are calling the same keyboard hotkey but only win+e
works. I’m hitting those hotkeys on Chrome browser.
If I change those mappings to a debugger output:
keyboard.add_hotkey('win+c', lambda: print('ctrl+c'))
keyboard.add_hotkey('win+v', lambda: print('ctrl+v'))
keyboard.add_hotkey('win+l', lambda: print('ctrl+l'))
keyboard.add_hotkey('win+e', lambda: print('ctrl+l'))
I do see the output on the console. Do you have any idea what could be cause these events to not be correctly processed by chrome?
P.S.: I don’t think it’s relative to Chrome, as the same hotkeys don’t work on other applications (e.g. termite).
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (6 by maintainers)
Top Results From Across the Web
Missing a Key? How to Remap and Fix Your Keyboard ...
Fix a Missing Key. Do you have a missing or broken key? Just map around it. It might take some adjustment because you'll...
Read more >Keybinds problem, can't map certain keys : r/TowerofFantasy
Keybinds problem, can't map certain keys. hi, i was wondering if some of you have a similar problem : My weapon skill and...
Read more >Unable to map some keys on Linux - Answers HQ
Unable to map some keys on Linux ... Mouse/keyboard settings menu ... Open game in Linux under steam, go to in-game settings, try...
Read more >Not able to map keys to Ctrl+Left or Ctrl+Right with ...
I'm wondering if it's some lingering settings on PowerToys, or did a recent Windows update blotch PowerToys' Keyboard Manager? My key mapping:
Read more >How to map a controller to keyboard keys on Windows 10
Map controller to keyboard. While most modern PC games have controller support, some of them offer better gameplay if you use a keyboard....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hmm, the suppress code is even trickier than the hotkey code, and was introduced by a pull request. I’ll have to take some time to check it, but it may take some days.
And by the way thanks for the bug reports. These are very useful.
Your code was not working because of the
keyboard.is_pressed(part)
part when checking if the hotkey has been completed. When the handler is called, the key has already been registered as released and therefore the check fails.The fix was indeed tricky, but I implemented on the master branch as a
trigger_on_release
flag. Please let me know if you find any problems with it.