Comments (29)
Just to get you moving @adamchenwei. If you're hardstuck on this issue you can use String.fromCharCode()
to get your desired keychar
.
ioHook.on("keydown", e => {
console.log(e.rawcode, String.fromCharCode(e.rawcode));
})
// Outputs something like:
// 69 "E"
This is of course just a low level solution since this doesn't consider things like localization or lower-/uppercase. But I still hope this does fit your case... 😊
from iohook.
Sorry, I'm still learning my way around the code. I noticed that the mask value actually represents the modifier... 0x1 is shift. I'll expose this in the event object.
from iohook.
@adamchenwei I'm working on that now. See #61 🎉
I'll reopen #62 to be merged and recommend using keypress actual character (keypress will indicate if it is upper or lower case).
from iohook.
Hi, can you try with keyup ?
from iohook.
@Djiit nop. still no keychar. Is it removed in certain version, accidentally?
from iohook.
According to #1 , it might be normal as keychar
is only present in the keypress
event. Could you test it ? I'll update the documentation if it's correct.
from iohook.
@Djiit keypress (NOT WORKING AT THIS MOMENT, USE keydown/keyup)
it says in doc.. and yes, its not working I just confirmed, it just stuck, not showing any log
from iohook.
Nice workaround ! I'll put it in the readme too in a "Tips" section.
from iohook.
absolutely a nice word around until a final feature is added, thanks @JanUnld and appreciate the follow up @Djiit ! You all are awesome!
from iohook.
I haven't close this issue just in case you all want this ticket to be used as a follow up otherwise feel free to close it!
from iohook.
You're welcome @adamchenwei ! I'll close this when the doc will be updated.
from iohook.
@JanUnld @Djiit just verified the work around a bit, but seems not really working correctly.
I am on MacOS High Seirra
console log the keydown event watch, what I got for a keydown on a
key, I got
0 '\u0000'
but in the https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode
I see
String.fromCharCode(65); "A"
maybe some clarification? Still new to this sort of low-level code
stuff hehe
from iohook.
You are right. According to #18 (note: I learnt a lot of thing digging into old issues :)), the keycodes are the one issued by libuiohook (Linux). So we might craft some sort of lookup table.
from iohook.
awesome! looking forward for the fix. this is pretty critical piece, really looking forward to the final fix! 👍
from iohook.
A bit more info : these keycodes are based on en-US standard keyboard so they are related to the "location" of keys on your keyboard... Sounds harder than expected.
from iohook.
btw, I saw this table http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlkeycodes.html
is that whats really it? some sort of mapping between what I see in the iohook to the key listed in the first left column?
from iohook.
Yep, only if you use a standard QWERTY keyboard
from iohook.
Couldn't we just show a warning if someone using non-standard keyboard? I mean seems another set DVORAK, nicer layout but almost below 1% is using them approx..... https://www.quora.com/What-percent-of-the-population-uses-Dvorak\
It can be realllllly awesome to have this feature in to take care of 99% of us and maybe improve and iterate?
from iohook.
i would have just make a javascript matcher lol but I guess its not very performant for this purpose. since seems everything is built with... other programming language...
from iohook.
It could work actually. Make a JS object with the good key/value pairs form the table above and wrap it in a function like keycodeToChar(keycode)
. We'll add it to the README for general use at first, and we could then discuss if it fits in this project (in the iohook object maybe ? to use it only when to want with e.g. iohook.keycodeToChar(e.keycode)
.
from iohook.
that sounds good!
from iohook.
but, one thing though, seems its still can't recognize capitalized input though ha.....
unless there is way we can make iohook see the difference?
from iohook.
I don't think so. Speaking of hardware/input, this is the same key :/ I think you can detect Shifted key, but capslocked key could be harder.
from iohook.
hum, ok, that's interesting though on that. I can build a small key matching file. let see how it goes~ thanks, lets keep updated.
from iohook.
This is how libuiohook displays key events:
We can add the character to the keypress event but keyup and keydown will always be the upper case character.
from iohook.
better than nothing, at least we can somehow handle with other lib to detect maybe pressing of Cap lock or Shift? or can iohoook do it already?
from iohook.
hey any chance of detecting caps lock?
from iohook.
@pitops I don't believe so. I think this would require implementation by libuiohook.
You could:
- Use the mask to track if the user has pressed capslock previously (mask 0x4000)
- Listen to the 'keypress' event and if there is no shift mask and the keychar is capital... assume it's a capslock.
from iohook.
Indeed this is directly linked to libuiohook not capturing CAPS_LOCK. Closing this for now.
from iohook.
Related Issues (20)
- --dist-url in `build.js` should be updated
- Doesn't work on any node version other than 13.14.0
- If you're stuck, use uiohook-napi instead! HOT 6
- Overlapping shortcuts
- how can import iohook into my web-application to get keyboard or mouse click event globally? HOT 1
- Is there a possibility to interrupt a keydown event?
- Update Electron Support HOT 2
- Cannot find module iohook.node HOT 2
- (node:72347) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 keydown listeners added to [IOHook]. Use emitter.setMaxListeners() to increase limit
- Unable to install iohook because of npm errors HOT 4
- How can check iohook is started or stopped
- iohook build different node js version HOT 15
- Update dist-url for build.js script
- Building for node v18.13.0 and Electron 22.0.0 HOT 3
- Release to github fails when manual build.
- Version 0.9.0 is not build for Windows 11 HOT 1
- Uncaught Exception: Error: Cannot find module '/home/logicrays/Documents/practice project/Learn electronjs/web-tracker-electron-app/node_modules/iohook/builds/electron-v113-linux-x64/build/Release/iohook.node' HOT 3
- Non-existing version of iohook, v0.9.3-node-v111-win32-x64 HOT 3
- Build a version for Electron v24.4.0 HOT 5
- Error to install over mac and nodejs v14 & v15 HOT 3
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 iohook.