KeyListeners with numpad?
awt, java, keylistener, numbers, user-interface
Solution
`KeyEvent.getKeyLocation()` returns the location of a key press.
// KeyEvent e
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD)
System.out.println("Numpad pressed!");
You can also use the keys `KeyEvent.VK_NUMPAD2`:
if (e.getKeyCode() == KeyEvent.VK_NUMPAD2)
System.out.println("Numpad 2 pressed!");
Problem
How do I use `KeyListeners` for the numpad? For example, if I make a `KeyListener` for 2, only the key for 2 on the standard keyboard works, not the numpad.