Code Monkey home page Code Monkey logo

Comments (29)

JanUnld avatar JanUnld commented on August 20, 2024 4

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.

matthewshirley avatar matthewshirley commented on August 20, 2024 2

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.

matthewshirley avatar matthewshirley commented on August 20, 2024 1

@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).

capture

from iohook.

Djiit avatar Djiit commented on August 20, 2024

Hi, can you try with keyup ?

from iohook.

adamchenwei avatar adamchenwei commented on August 20, 2024

@Djiit nop. still no keychar. Is it removed in certain version, accidentally?

from iohook.

Djiit avatar Djiit commented on August 20, 2024

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.

adamchenwei avatar adamchenwei commented on August 20, 2024

@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.

Djiit avatar Djiit commented on August 20, 2024

Nice workaround ! I'll put it in the readme too in a "Tips" section.

from iohook.

adamchenwei avatar adamchenwei commented on August 20, 2024

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.

adamchenwei avatar adamchenwei commented on August 20, 2024

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.

Djiit avatar Djiit commented on August 20, 2024

You're welcome @adamchenwei ! I'll close this when the doc will be updated.

from iohook.

adamchenwei avatar adamchenwei commented on August 20, 2024

@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.

Djiit avatar Djiit commented on August 20, 2024

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.

adamchenwei avatar adamchenwei commented on August 20, 2024

awesome! looking forward for the fix. this is pretty critical piece, really looking forward to the final fix! 👍

from iohook.

Djiit avatar Djiit commented on August 20, 2024

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.

adamchenwei avatar adamchenwei commented on August 20, 2024

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.

Djiit avatar Djiit commented on August 20, 2024

Yep, only if you use a standard QWERTY keyboard

from iohook.

adamchenwei avatar adamchenwei commented on August 20, 2024

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.

adamchenwei avatar adamchenwei commented on August 20, 2024

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.

Djiit avatar Djiit commented on August 20, 2024

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.

adamchenwei avatar adamchenwei commented on August 20, 2024

that sounds good!

from iohook.

adamchenwei avatar adamchenwei commented on August 20, 2024

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.

Djiit avatar Djiit commented on August 20, 2024

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.

adamchenwei avatar adamchenwei commented on August 20, 2024

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.

matthewshirley avatar matthewshirley commented on August 20, 2024

This is how libuiohook displays key events:

capture

We can add the character to the keypress event but keyup and keydown will always be the upper case character.

from iohook.

adamchenwei avatar adamchenwei commented on August 20, 2024

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.

pitops avatar pitops commented on August 20, 2024

hey any chance of detecting caps lock?

from iohook.

matthewshirley avatar matthewshirley commented on August 20, 2024

@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.

Djiit avatar Djiit commented on August 20, 2024

Indeed this is directly linked to libuiohook not capturing CAPS_LOCK. Closing this for now.

from iohook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.