Comments (23)
Yeah is there any way to detect when user pressed a deadkey to possibly be composing a combined character? We have a lot of those in Icelandic and none seem to work, so far I've tried áíóéýú
with no luck
from pynput.
Okay I just figured out I can use KeyCode.from_dead('`').join(KeyCode.from_char('e'))
to combine deadkeys with others and create a combined character but they don't show up right. They show up as grave (è) when they should show up as acute (é). Is there any way around this ?
from pynput.
Thank you for your report.
I will look into the issue with disappearing second characters shortly.
@logileifs Did you paste the code correctly? You seem to be joining a grave accent (`) with an e, which should indeed produce è.
from pynput.
Silly mistake of me, you're absolutely right, I was using the wrong one. One question though, does pynput provide any information on when a dead key is pressed? Or is it just treated as any other alphanumeric character?
from pynput.
Logileifs, can you show me how exactly to use KeyCode.from_dead?
I probably need it in an if ... then structure.
from pynput.
@SpecialCharacter just exactly like I posted in the comment above. You put your dead key in from_dead
and your combining key in from_char
. So to produce an è you would do KeyCode.from_dead('`').join(KeyCode.from_char('e'))
from pynput.
The problem is that I need something like
if key.char == 'M':
elif memory[-2:-1] == '`':
KeyCode.from_dead('`').join(KeyCode.from_char('M'))
But how do I print it? I suppose with keyboard.type?
from pynput.
KeyCode.from_dead('`').join(KeyCode.from_char('M'))
returns a pynput KeyCode object but you can access its character with .char
. So something like this should work:
ḿ = KeyCode.from_dead('`').join(KeyCode.from_char('M'))
print(ḿ.char)
from pynput.
@logileifs it does not work for me :(
As pynput hides the second character after a deadkey from its memory, the triggering event is never released.
Does it work for you?
from pynput.
well I had not tried it in action yet, only in the interactive interpreter. I just assumed I could catch the deadkeys with something like
if key.char == '´' or key.char == '`':
dead = key.char
# next key release:
combined_char = KeyCode.from_dead(dead).join(KeyCode.from_char(second_key.char))
I'll try it out and report back how it goes
from pynput.
@SpecialCharacter I can confirm that it's working for me with the logic above. It's just some pseudo code with the important bits from my code but if you need further clarification I can post some actual samples from my code, just let me know
from pynput.
@SpecialCharacter Did the solution provided by @logileifs help you?
from pynput.
from pynput.
Also, now I get a name error:
m̀ = KeyCode.from_dead(dead).join(KeyCode.from_char('m'))
NameError: name 'KeyCode' is not defined
from pynput.
You will have to import KeyCode
.
from pynput.
from pynput.
Still not working :(
if key.char == '
':`
`dead = key.char`
`# next key release:`
`if key == 'm':`
`m̀ = KeyCode.from_dead(dead).join(KeyCode.from_char('m'))`
'# dead('`') does not do it either`
`keyboard.type(m̀.char)`
key ['´'] released [acute]
´
key Key.shift_r released
key '' released ´
[acute, grave]
I type: `m
Why does pynput do the acute when I type the grave?
And the m does not show up?
from pynput.
OK, now the code ALMOST works - if I delete
if key == 'm':
But that means it ALWAYS prints m̀!
How do I get it to respect what character I type after the deadkey?
from pynput.
@logileifs By the way, your m̀ code works!
It just won't let me select the second character… any hint how to do it?
from pynput.
Hi, has somebody come up with a solution how to make the virtual dead key visible to pynput?
from pynput.
Oh, and also Windows splits again ` (grave) into:
key Key.shift_r released
key ['´'] released # (acute)
This behaviour is very annoying. Can you think of a way to fix it?
I mean, there is a difference between m and M, so why not between ` (grave) and ´ (acute)?
from pynput.
Hi again… so has somebody come up with a solution how to make the virtual dead key (not visible to pynput) into a real dead key? It works in Autohotkey, so why not in Python?
from pynput.
I have created issue #49 as a container for all win32 keyboard listener related issues, as I suspect that the root cause is the same.
I will close this issue. If you think the problem is unrelated to #49, please reopen this issue.
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 4
- 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.