Java provides a means for identifying modifier keys. By modifier keys, I mean
- Alt - e.isAltDown ();
- Ctrl - e.isControlDown ();
- Shift - e.isShiftDown ()
These achachas connect to other keys on the regular keyboard from the keyboard to determine if a combination has been pressed.
if( (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_X) )
{
}
e.getModifiers () can be used to identify the modifier, as well as the click of a mouse. This returns a bitmask.
See here. http://www.leepoint.net/notes-java/GUI-lowlevel/keyboard/keyboard.html
Ctrl. , .
JTextField sampleTxtFld= new JTextField();
sampleTxtFld.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e)
{
if((e.isControlDown() && e.getKeyCode() == KeyEvent.VK_X)
{
}
}
public void keyReleased(KeyEvent e)
{
}
public void keyTyped(KeyEvent e) {
}
});