Can anybody provide me with the Key Code integer list for individual keys used on the Keyboard for the KeyEvent class in java?
I want to create a dropdown list of all the keyboard keys for the user to select. I need the list specific to Keyboard. The VK constants does not help in this case because I need a 'list' of Keys used on the Keyboard. This post here didn't come of use because it's for Javascript and the codes aren't the same for all keys comparing with the javadoc. Also the KeyCode values used in javadoc are all arranged in Alphabetical Order, so it's hard to find the Keyboard keys over there. I tried googling for sources but nothing interesting came up just the Javascript one. Should I just compile them one by one myself or is there an easier way?
Edit: I know about VK. I need to use KeyEvent.getKeyText function to store each of the keyboard keys in a dropdown menu. So i need the list. That's why I asked should I need to compile them myself. I should have mentioned that earlier. It would be a waste of time doing that for each key.
KeyEvent class has static fields with these values.
For example, KeyEvent.VK_A
represent "A" key.
To get the fields names you can use reflection:
Field[] fields = java.awt.event.KeyEvent.class.getDeclaredFields();
for (Field f : fields) {
if (Modifier.isStatic(f.getModifiers())) {
System.out.println(f.getName());
}
}