|
2 years ago | |
---|---|---|
src | 2 years ago | |
README.md | 2 years ago | |
pom.xml | 2 years ago |
A Java/Native global keyboard hook.
Using the library is as simple as adding a Maven dependency and a few lines to handle the events.
<dependency>
<groupId>com.mclarkdev.tools</groupId>
<artifactId>KeyHook</artifactId>
<version>1.0</version>
</dependency>
Create an EventListener to handle the keyboard events.
private EventListener eventListener = new EventListener() {
@Override
public void onEvent(ArrayList<Integer> keyMap) {
String keys = keyMap.stream().map(Object::toString)//
.collect(Collectors.joining(", "));
System.out.println("Keys:" + keys);
}
};
Attach the listener to the KeyboardManager.
KeyboardManager.getInstance().attachListener(eventListener);