This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Listen to Caps Lock Key event

 
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
 
Rancher
Posts: 3063
23
  • 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


 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!