I want to trigger all keyboard inputs (also strg, alt and tab) in a JTextField.
super.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent arg0) {
System.out.println(arg0.getKeyChar());
}
@Override
public void keyReleased(KeyEvent arg0) {
}
@Override
public void keyPressed(KeyEvent arg0) {
}
});
KeyListener does not trigger keyboard inputs like strg, alt or / and tab.
Is there a solution for this case?
I need this for a settings screen, where the user can change the key, which must be pressed for a action like moving forward.
This works for me, I had to disable traversal in order to catch the
Tabkey.Also note that the
keyTyped()event is never called for keys likeAlt,ShiftorControl.But you can catch them when you use the
keyPressed()orkeyReleased()events: