-
Notifications
You must be signed in to change notification settings - Fork 287
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
How to get the actual character typed? #214
Comments
@ackvf Instead of |
@Richienb |
@ackvf It works for me. Check the version you have installed. |
I have just updated from |
@ackvf Try this code: const iohook = require("iohook")
iohook.start()
iohook.on("keypress", ({ keychar }) => console.log(`Key pressed: ${String.fromCharCode(keychar)}`)) |
I have the same behaviour of you, and I think it's a bug because a few week ago, I didn't think I had this problem |
I'm able to get the unicode keychar in the keydown event similar to the keypress event by modifying a couple of source files and rebuilding Replace line 364 in input_hook.c with: Change line 447 in iohook.cc: I tested only on a Mac, but similar changes should apply for Windows by replacing line 226 in input_hook.c file for Windows with: |
I used
String.fromCharCode(key.rawcode)
to obtainQ Q
and1 1
even though I really typedq Q
and+ 1
. In other words, I get the same character code for lower and capital form of a letter. Notice howkeypress
library handles that.While your solution is far superior with regard to giving same output with different layouts, it is useful to also get the actual character typed.
I pressed
![image](https://user-images.githubusercontent.com/2313018/73125366-3f756280-3fa6-11ea-8a45-047d5aee767e.png)
q =
q
shiftq =
Q
I pressed
![image](https://user-images.githubusercontent.com/2313018/73125171-118f1e80-3fa4-11ea-9015-049555505b0a.png)
+ =
+
shift+ =
1
(Czech Qwerty layout )The text was updated successfully, but these errors were encountered: