Converting a Char into Java KeyEvent KeyCode

后端 未结 4 1648
独厮守ぢ
独厮守ぢ 2020-11-30 12:40

I am writing a basic program that asks the user to type in a String, and I am trying to use a Robot (from java.awt.Robot)that will type this message back into a

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 13:07

    If I have a unicode character and all I want is to know the keystroke for it, then I use

    int keyCode = java.awt.event.KeyEvent.getExtendedKeyCodeForChar(charCode);
    

    I've never needed another, more complicated way to do this.

提交回复
热议问题