JDK-6427310 : Function to get the state of a key
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P5
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86
  • Submitted: 2006-05-18
  • Updated: 2011-04-29
Related Reports
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
It would be nice to have a function to get the state of a key. E.g. I need to detect in my mousewheel listener if the Ctrl key is down or not.
So I propose to add a function like this: boolean getKeyState(int key)
so I can use getKeyState(KeyEvent.VK_Control) to see if the key is down at the moment the function is called.

JUSTIFICATION :
It would be nice to have a function to get the state of a key. E.g. I need to detect in my mousewheel listener if the Ctrl key is down or not.
So I propose to add a function like this: boolean getKeyState(int key)
so I can use getKeyState(KeyEvent.VK_Control) to see if the key is down at the moment the function is called.	


ACTUAL -
no possibility to get a keyState

Comments
EVALUATION We already have similar one: 4083501 and it describes the problem in a whole for input devices.
25-05-2006

EVALUATION You can detect if the CTRL key is down by asking the MouseWheelEvent with getModifiers() or getModifiersEx(). However, the request for querying key state sounds interesting. Re-assigning to AWT to evaluate this.
24-05-2006