JTextArea new line on shift + enter

后端 未结 3 1715
南笙
南笙 2021-02-08 23:31

I\'ve added a keylistener to my JTextArea field, but it doesn\'t behave as I expected.

inputTextArea.addKeyListener(new KeyAdapter() {
public void keyPressed(Key         


        
3条回答
  •  [愿得一人]
    2021-02-08 23:51

    Try using keyTyped and not keyPressed. I beleive keyPressed gives you an event for the shift and for the enter, whereas keyTyped gives you one combined event with a modifier.

提交回复
热议问题