Get the VK int from an arbitrary char in java

前端 未结 8 992
孤街浪徒
孤街浪徒 2020-12-31 17:17

How do you get the VK code from a char that is a letter? It seems like you should be able to do something like javax.swing.KeyStroke.getKeyStroke(\'c\').getKeyCode()<

8条回答
  •  猫巷女王i
    2020-12-31 18:02

    AWTKeyStroke.getAWTKeyStroke('c').getKeyCode();
    

    Slight clarification of Pace's answer. It should be single quotes (representing a character), not double quotes (representing a string).

    Using double quotes will throw a java.lang.IllegalArgumentException (String formatted incorrectly).

提交回复
热议问题