Missing keypress
michelvermeulen opened this issue · 11 comments
Hi!
Thanks for working on this. One thing I'm missing from the original iohook implementation is the keypress event which contains a "keychar" property that allows to transform a keycode into its matching key. I tried using the UiohookKey import but it doesn't work with the / key for instance (52 vs 53).
Do you have any insight on this?
I intentionally don't expose this in events, interpreting keycodes into actual characters according to KB layout is gray area of keyloggers. Adding them back is really trivial, you can do it in fork.
Hi Snos. Thanks for your reply. Still struggling with that, and I have no idea how to add them back although it looks really trivial. Could you help me out here?
Here I'm exposing only keycode
Lines 61 to 62 in 63745a5
But you can add another js property with keychar
You may also need to uncomment this
uiohook-napi/src/lib/uiohook_worker.c
Line 68 in 63745a5
Thanks a lot! I'll try to get by with that info, I'm really not familiar with C so I'll fiddle around. Thanks again, I'll reach back if I can't work this out, happy to sponsor you at a personal level if I need more help :)
I guess I'll have to rebuild it to see changes after I change the source files?
Alright @SnosMe, I'm almost there. I added the keychar, but the value is different from what ioHook sends (ioHook sends 113 for q on my keyboard while uiohook always sends 65535.
This is what I added:
napi_value e_keychar;
status = napi_create_uint32(env, event->data.keyboard.keychar, &e_keychar);
NAPI_FATAL_IF_FAILED(status, "uiohook_to_js_event", "napi_create_uint32");
If you uncommented line I've mentioned,
and added new if block with that event type, then idk
Line 60 in 63745a5
Oh, also if you apply my patch I remove that code for some reason 😅
uiohook-napi/src/libuiohook.patch
Lines 148 to 174 in 63745a5
I actually don't have the patch. I did everything yes, I do have warnings when doing node-gyp build:
CC(target) Release/obj.target/uiohook_napi/src/lib/addon.o
../src/lib/addon.c:305:53: warning: passing 'int32_t *' (aka 'int *') to parameter of type 'uint32_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]
status = napi_get_value_uint32(env, info_argv[1], (int32_t*)&tap_type);
^~~~~~~~~~~~~~~~~~~
/Users/michel/Library/Caches/node-gyp/18.12.1/include/node/js_native_api.h:140:68: note: passing argument to parameter 'result' here
uint32_t* result);
What's weird is the keychar is always the same value no matter which key I press: 65535
from this code it looks like keycode and keychar are swapped on macOS in uiohook 😄
or is it you changing code to debug it