Home > Software engineering >  Convert VKCode to String Java
Convert VKCode to String Java

Time:04-22

As the title suggests I want to convert a string to VK code, my original idea was to have:

HashMap<char,(what)> map= new HashMap<>();
map.put('A',KeyEvent.VK_A);

And do that for all the values then loop through the string but I don't know if anything like that is possible.

Is the best way just to have a switch for every character?

CodePudding user response:

The VK constants appear to be ints, so you should just have a Map<Character, Integer>.

Alternately, you could use getExtendedKeyCodeForChar, passing in the char, to get the key code.

  • Related