-
Enhancement
-
Resolution: Fixed
-
P4
-
7-pool
When listening for key pressed and key released events it is often useful to know what *kind* of key, the user released, e.g. was it an F-key (F1, F2, ...), an arrow key, or perhaps a modifier key (like Ctrl).
Currently, if I want to know if the user released any kind of function key, I will have to write quite elaborate code like
if(keyEvent.getCode() == KeyCode.F1 || keyEvent.getCode() == KeyCode.F2 || keyEvent.getCode() == KeyCode.F3 || ... ... ...)
To avoid this, I am requesting the addition of a number of key classification methods, that would allow me to check if the user hit any kind of function key with a single method like this
if(keyEvent.isFunctionKey())
I think a natural set of methods could be
KeyEvent.isFunctionKey() //F1, F2, F3, ..., F24
KeyEvent.isArrowKey() //UP, DOWN, LEFT, RIGHT
KeyEvent.isModifierKey() //Ctrl, Alt, Shift, Meta
KeyEvent.isMediaKey() //VOLUME_UP, PLAY, PAUSE, REWIND, ...
KeyEvent.isLetterKey() //A, B, C, ..., Z plus all other keys for which Character.isLetter returns true (to get national keys like Æ, Ø, Å as used in countries like Denmark, Sweden, Germany, etc.)
KeyEvent.isDigitKey() //1, 2, 3, ..., 0 above the QWERTY keys as well as 0, 1, 2, ..., 9 on the numeric key pad
KeyEvent.isQwertyDigitKey() //1, 2, 3, ..., 0 above the QWERTY keys
KeyEvent.isKeypadDigitKey() //0, 1, 2, ..., 9 on the numeric key pad
Currently, if I want to know if the user released any kind of function key, I will have to write quite elaborate code like
if(keyEvent.getCode() == KeyCode.F1 || keyEvent.getCode() == KeyCode.F2 || keyEvent.getCode() == KeyCode.F3 || ... ... ...)
To avoid this, I am requesting the addition of a number of key classification methods, that would allow me to check if the user hit any kind of function key with a single method like this
if(keyEvent.isFunctionKey())
I think a natural set of methods could be
KeyEvent.isFunctionKey() //F1, F2, F3, ..., F24
KeyEvent.isArrowKey() //UP, DOWN, LEFT, RIGHT
KeyEvent.isModifierKey() //Ctrl, Alt, Shift, Meta
KeyEvent.isMediaKey() //VOLUME_UP, PLAY, PAUSE, REWIND, ...
KeyEvent.isLetterKey() //A, B, C, ..., Z plus all other keys for which Character.isLetter returns true (to get national keys like Æ, Ø, Å as used in countries like Denmark, Sweden, Germany, etc.)
KeyEvent.isDigitKey() //1, 2, 3, ..., 0 above the QWERTY keys as well as 0, 1, 2, ..., 9 on the numeric key pad
KeyEvent.isQwertyDigitKey() //1, 2, 3, ..., 0 above the QWERTY keys
KeyEvent.isKeypadDigitKey() //0, 1, 2, ..., 9 on the numeric key pad