How can I find out the state of capslock?

Although I can use KeyEvent#shift_down to find out if the shift key was
held down when a key is pressed, I don’t know how to find out if the
capslock key is in effect (the capslock key was pressed the capslock LED
is on, and other programs are treating an ‘a’ keypress as an ‘A’). I
could catch capslock keypresses by checking evt.get_key_code for 311,
but don’t know what the starting capslock state is since it might have
been set when the user was in another program. Can someone tell me how
to find out what what the capslock state is?

Thanks, Ross

Hi Ross

Ross Goodell wrote:

Although I can use KeyEvent#shift_down to find out if the shift key was
held down when a key is pressed, I don’t know how to find out if the
capslock key is in effect (the capslock key was pressed the capslock LED
is on, and other programs are treating an ‘a’ keypress as an ‘A’). I
could catch capslock keypresses by checking evt.get_key_code for 311,
but don’t know what the starting capslock state is since it might have
been set when the user was in another program. Can someone tell me how
to find out what what the capslock state is?
Wx::get_key_state(Wx::K_CAPITAL)

Wx::get_key_state is a global method that returns true/false depending
on whether the key with the specified code is currently depressed.
Specially, for the toggle “lock” keys num / caps / scroll (whose integer
key codes are Wx::K_NUMLOCK, Wx::K_CAPITAL and Wx::K_SCROLL) it instead
returns true if the relevant lock is currently on.

a

Alex F. wrote:

Hi Ross

Ross Goodell wrote:

Although I can use KeyEvent#shift_down to find out if the shift key was
held down when a key is pressed, I don’t know how to find out if the
capslock key is in effect (the capslock key was pressed the capslock LED
is on, and other programs are treating an ‘a’ keypress as an ‘A’). I
could catch capslock keypresses by checking evt.get_key_code for 311,
but don’t know what the starting capslock state is since it might have
been set when the user was in another program. Can someone tell me how
to find out what what the capslock state is?
Wx::get_key_state(Wx::K_CAPITAL)

Wx::get_key_state is a global method that returns true/false depending
on whether the key with the specified code is currently depressed.
Specially, for the toggle “lock” keys num / caps / scroll (whose integer
key codes are Wx::K_NUMLOCK, Wx::K_CAPITAL and Wx::K_SCROLL) it instead
returns true if the relevant lock is currently on.

a

Thanks Alex for replying so quickly. It worked beautifully.

Ross