status of the key

  • Thread starter Thread starter Pohihihi
  • Start date Start date
P

Pohihihi

How to get the status of any key (e.g. Caps, Insert etc). I need to display
below on the form if insert/caps is enabled.

Thanks.
 
Pohihihi,

You can call the GetKeyState function through the P/Invoke layer. This
will allow you to pass a virtual key to the function, and it will return an
integer where the high order bit is set to one if it is down.

For toggle keys, like caps lock, and insert, then the low order bit will
be set to one, otherwise, it will be set to 0.

Hope this helps.
 
Thanks.


Nicholas Paldino said:
Pohihihi,

You can call the GetKeyState function through the P/Invoke layer. This
will allow you to pass a virtual key to the function, and it will return
an integer where the high order bit is set to one if it is down.

For toggle keys, like caps lock, and insert, then the low order bit
will be set to one, otherwise, it will be set to 0.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Pohihihi said:
How to get the status of any key (e.g. Caps, Insert etc). I need to
display below on the form if insert/caps is enabled.

Thanks.
 
Back
Top