Comments (7)
I have pushed a fix to the master branch.
Instead of always using XSendEvent
, which is necessary to handle multiple layouts, pynput no uses XFAKE for control keys.
Please notify if this fixes your issue---it worked for my local tests.
from pynput.
Thanks for the quick fix, Moses. Now Key.ctrl, Key.shift, Key.alt and Key.cmd send non-synthetic keys. I can use Key.cmd for example to trigger the application menu.
However, Key.tab still sends a synthetic key, which still doesn't trigger application switching:
KeyRelease event, serial 38, synthetic YES, window 0x4e00001,
root 0x498, subw 0x0, time 0, (0,0), root:(0,0),
state 0x0, keycode 23 (keysym 0xff09, Tab), same_screen NO,
XLookupString gives 1 bytes: (09) " "
XFilterEvent returns: False
Side question: What happens if all keys, including normal letter keys, are sent as non-synthetic?
from pynput.
I quickly checked the documentation for (XSendEvent)[https://tronche.com/gui/x/xlib/event-handling/XSendEvent.html] and XKeyEvent, and it does not seem to support manipulating the synthetic flag. PyUserInput uses XFAKE, which is a server extension, for sending fake events; I presume this is why it can set the flag.
Normal letters cannot be sent through XFAKE if a general solution compatible with the pynput API guarantees is sought; XFAKE does not support sending keys not mapped in the layout, and maintains its own modifier mapping.
I have pushed a new set of commits; now all keys with a known virtual key code are sent through XFAKE, thus allowing control keys and modifiers to be non-synthetic. I extended my local tests with alt+tab, and that too works now.
from pynput.
Hey, you're very quick! It works beautifully now. =) Thanks very much!
from pynput.
Hmm, something has changed though. Example:
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
from pynput.keyboard import Key, Controller
keyboard = Controller()
keyboard.press('a')
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.linux-x86_64/egg/pynput/keyboard/_base.py", line 371, in press
File "build/bdist.linux-x86_64/egg/pynput/keyboard/_xorg.py", line 204, in _handle
File "/usr/lib/python2.7/contextlib.py", line 24, in exit
self.gen.next()
File "build/bdist.linux-x86_64/egg/pynput/_util/xorg.py", line 76, in display_manager
pynput._util.xorg.X11Error: [(BadValue(), None)]
I installed pynput just now from 024dfd7
from pynput.
I had a feeling this would be one of those ;-)
I made the mistake of not running the test suite after the modifications; it was so small, right?
I have pushed yet another set of commits that changes the default value of pynput.KeyCode.vk to None
, which is a saner value, and what the previous patch expected.
Thank you for your input and testing!
from pynput.
Thanks again, Moses. Your new commits fixed the issues. From what I could tell, everything works perfectly now. Maybe you'll want to close this issue to keep your issue tracker clean again.
Thanks for the great work!
from pynput.
Related Issues (20)
- Which python version is the latest release of pynput compatible with?
- Keyboardtracking CTRL + "second_key" doesn't output "second_key"
- pynput not detecting media keys on kde plasma wayland HOT 1
- Type method crashes on cyrillic characters HOT 1
- Suppress mouse move not working when using parsec HOT 1
- mouse listener example for win32_event_filter HOT 1
- Script Continues Rapid Clicking Despite Mouse Button Release (is_pressed Functionality Issue) HOT 6
- Press cmd_r and release with cmd pressed will produce two presses instead of press + release HOT 3
- Can this be used in Micropython? HOT 5
- Get the original pressed key HOT 1
- The Numpad numbers does not work in HotKeys.
- pynput types ">" instead of "|" HOT 1
- Need to sync keyboard lock keys
- AttributeError: record_create_context HOT 5
- capslock crshed on macOS HOT 2
- lazy imports cause a KeyError HOT 4
- Cannot install on linux Ubuntu (depends on pywin32) HOT 2
- name 'keyboard' is not defined HOT 1
- Additional keys can still trigger events HOT 2
- Missing 1.7.7 tarball on PyPI
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 pynput.