Author Topic: Caps Lock Key  (Read 3144 times)

outsider

  • Community Member
  • Posts: 64
  • Hero Points: 1
Caps Lock Key
« on: July 03, 2011, 11:58:33 AM »
Good afternoon all you wonderful Slick Edit people.

is there any way of trapping whether the caps lock key is down?

I can see there is an on_scroll_lock() event in the docs but not for the lowly caps key.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Caps Lock Key
« Reply #1 on: July 04, 2011, 12:01:35 PM »
On Windows you could have a C function in a DLL to tell you

http://vcpptips.wordpress.com/2009/01/19/how-to-check-the-caps-lock-is-on-or-off/

Or you could call an external program using shell() which "calls you back" using something like vs.exe -r caps_lock_is_on

http://www.qtcentre.org/threads/30180-how-to-determine-if-CapsLock-is-on-crossplatform


outsider

  • Community Member
  • Posts: 64
  • Hero Points: 1
Re: Caps Lock Key
« Reply #2 on: July 04, 2011, 02:01:21 PM »
Thanks Graeme,

It looks like there is no direct way of doing this so I think I'm going to have to check your indirect solutions out.

Thanks once again!

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6884
  • Hero Points: 530
Re: Caps Lock Key
« Reply #3 on: July 13, 2011, 06:01:25 PM »
Graeme's suggested solutions are correct.

There is an _IsKeyDown function in Slick-C but currently it only supports VSEV_CTRL and VSEV_SHIFT. On Windows, it ends up calling GetAsyncKeyState which supports checking many more keys. It doesn't support more keys primarily due to concerns with portability. NumLock, CapsLock, and ScrollLock support would be nice though.