开发者

How to listen to press more buttons on the keyboard?

开发者 https://www.devze.com 2023-03-05 14:42 出处:网络
I on the keyboard a lot more buttons, and I really need to listen t开发者_运维知识库o push the buttons (multimedia play, stop ..).

I on the keyboard a lot more buttons, and I really need to listen t开发者_运维知识库o push the buttons (multimedia play, stop ..).

How do it?

And I would like to catch the event, even when the window is minimized.


Use this jintellitype to catch key events outside your app in Windows. Here is for linux JXGrabKey

Update: to use multimedia buttons, you need to know it's codes. Add this listener to your app's frame to find out codes:

class MyKeyListener extends KeyAdapter {
  public void keyPressed(KeyEvent evt) {
    System.out.println("Key code: " + evt.getKeyCode());       
  }
}

If you will know the code, just check if evt.getKeyCode() is what you need and make some actions.

0

精彩评论

暂无评论...
验证码 换一张
取 消