How can I get the keyboard scan code in java?

后端 未结 2 1624
孤街浪徒
孤街浪徒 2020-12-03 23:39

I would like to write an application where the keybindings are specific to the location of the key on the keyboard, not the character they are mapped to. For example, the ke

2条回答
  •  猫巷女王i
    2020-12-04 00:01

    As MadProgrammer said: You have to use JNA or JNI. You can also have a look at those projects:

    • jintellitype (Windows only)

    JIntellitype is a Java API for interacting with Microsoft Intellitype commands as well as registering for Global Hotkeys in your Java application. The API is a Java JNI library that uses a C++ DLL to do all the communication with Windows.

    There are similar projects Linux and Mac OS X.


    • JNativeHook (Windows, Linux and Mac OS?)

    JNativeHook is a library to provide global keyboard and mouse listeners for Java. This will allow you to listen for global shortcuts or mouse motion that would otherwise be impossible using pure Java. To accomplish this task, JNativeHook leverages platform dependent native code through Java's native interface to create low level system wide hooks and deliver those events to your application.


    • Java – Global (low level) Keyboard / Mouse Hook (Windows only)

    Windows only, capable of Win 7 / 8 (32 and 64 bit)


    • JNA Keyboard Hook in Windows

提交回复
热议问题