• Post Reply Bookmark Topic Watch Topic
  • New Topic

Listen to Caps Lock Key event

 
Jack clouseau
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

There is an requirement in our RCP application where in if the user releases the CAPS LOCK key then we need to update something in our application based on the state of the CAPS LOCK key state.

Basically the user can be in any screen in the application and throughout the application this functionality remains the same....

I tried adding the KeyLister to the active shell in the workbench(we have only one active shell in our application)....but the keyEvents is not delegated to this shell...

Can anyone please give me some hint how to solve this issue....


quick reply is much appreciated....


Thanks
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never tried it for the Caps Lock key, but you should be able to use a Global Event Listener.

Otherwise you can query the state of the key using the Toolkit.getLockingKeyState, so maybe you can periodically check the value.
 
Jack clouseau
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:I've never tried it for the Caps Lock key, but you should be able to use a Global Event Listener.

Otherwise you can query the state of the key using the Toolkit.getLockingKeyState, so maybe you can periodically check the value.


Hi Rob,

Thanks for the reply...

i tried with the Toolkit.getLockingKeyState method also...but it updates only when the application starts for the first time....and it doesn't update immediately as soon as the user
releases the Caps Lock

So now am trying to get the state of this key directly from the OS...something like this

OS.GetKeyState(OS.VK_CAPITAL)...this is updating properly as soon as the user releases the key.

But am not sure whether this will be supported in all the Operating systems...and also if we are using like this Eclipse immediately show the "DisCouraged Access"....so am bit worried here!!!

Could anybody share their thoughts on the solution that i have? can i go ahead and implement this solution?


Thanks


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!