-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
value for key.space is ' ' #609
Comments
What makes you expect it to be 32? |
maybe i wasnt really to clear but in the case (as it is now) i would expect it to be 32 as that is the PS/2 keycode for space (the value of the key the keyboard sends ) all other keys that have the key.value properties use the ps/2 code in their value field. however not all keys have the value property , specifically the ones with the key.char property usually dont , they instead send the character they represent, wich is what space now does but in the value property so key.space now sends wich is not consistent with all the rest of the keys two solutions that would make it valid would be: |
My test run of the provided code gives:
If I see it right there are more inconsistencies in the logic of the keycode, the character and the value than in the case of the space character. |
It's all pure Python code only ... but ... somehow I failed to find the lines in code which decide about the assignment of values to the event properties and failed also to develop an idea how could it come that space is treated differently. Maybe you can try? |
Yes ... breaking past code is what I have already mentioned as reason for not touching it, in spite of the fact it shoudn't be this way. Once it has happened the bug becomes a feature and with plenty of code relying on such behavior there is no way to get it right. |
yeah i have been looking into , adding both .char and .value to the space key , then overload eq to check for both, also tought other keys might benefit from that behavior, or something similar (eg enter matching both the ascii keycode , aswell as '\n' and '\cr\lf') but im running lost in the code where half he time wer passing around classes instead of objects so it seems wich kind of makes it hard for me to wrap my head around the whole ps every key could just have a .value since it would be just the keyboardcode send by that key. just not every key has a corresponding char... |
Description
when using pynput listener , the key returned by the callback for the key , has its value set to ' ' whereas other keys use the PS/2 keycode instead (for the keys that have the value property set) think it would make more sense to either include space key with the keys that only have char defined , or leave it as it is but replace the value of the key to be
32
Platform and pynput version
Distro : Gentoo Linux 2.14 , kernel : 6.6.8
Python : Python 3.11.7 , Pynput 1.7.7
To Reproduce
outputs:
expected:
The text was updated successfully, but these errors were encountered: