Jump to content

Which key was pressed, not it's value?


VAN0
 Share

Recommended Posts

Is there a way determine what actual key was pressed and not what value it represents? (also, if possible, restrict to GUI only, not entire system, don't want to end up with a keylogger)

I've tried so far WH_KEYBOARD and WH_KEYBOARD_LL events and both return keys combination result, not actual keys. For example it returns the same code for End key and Shift + Num1

So, I guess I'm looking for some sort of "raw" keyboard input event?

Thank you.

 

P.S.

I'm trying to create my own hotkey input field, because windows built-in msctls_hotkey32 type doesn't support Win key and other combinations which we can set with HotkeySet()

Edited by VAN0
Link to comment
Share on other sites

Wrong forum ?  Wrong key ?

I suppose you mean Ins key and Shift + Num 0 give the same scan code and the same vkey, right ?

But you can distinguish the two keys by using the Extended flag provided by WH_KEYBOARD...

Link to comment
Share on other sites

Posted (edited)

Sorry, yes, wrong forum, and yes, Ins key (or in my case it was actually Num 1, so potato potato)

Somehow in my tests I've missed that flag, only saw it being triggered in WH_KEYBOARD_LL, not in WH_KEYBOARD

Now after more tests, I'm getting different results than the docs say. For example numpad keys don't trigger extended flag, but Ins, home, pgup, etc do...

Also, interestingly, pressing Num nn while holding Shift triggers 2 events: keyup for the Num nn (correction: Shift) key and keydown for the whatever secondary equivalent of that key, like Ins

Edited by VAN0
Link to comment
Share on other sites

Yes I got same results as you on extended flag and key up on shift. 

For the extended flag, it is true that docs is not exact, but the importance is that the flag allows to differentiate both set of keys. 

As for Shift down on num keys, it seems that keyboard forces a shift up.  But vkey is not the same when shift is pressed and is not pressed, so again we got a way to differentiate keys.

Overall, that makes management of the keyboard a bit tricky, but still consistent and doable.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...