Introduction | Getting started | Troubleshooting
jwinkey
is a windowless/global keyboard and mouse listener for Windows written in Java. It works by using the windows api in order to work even if the window isn't focused or hidden.
You are a Go developer? Check this out: https://github.com/daspoet/gowinkey/
To use jwinkey
with Gradle or Maven, check out the documentation of jitpack [here]
In order to observe for keyboard interactions, you need to create a KeyStateObservable
with an array of VirtualKey
which contains all keys that the given observer will look for.
import dev.lukasl.jwinkey.enums.VirtualKey;
import dev.lukasl.jwinkey.observables.KeyStateObservable;
KeyStateObservable observer = KeyStateObservable.of(Arrays.asList(
VirtualKey.VK_SHIFT,
VirtualKey.VK_LEFT_SHIFT,
VirtualKey.VK_RIGHT_SHIFT
));
After creating the observer in the step above, you can append different consumers to the observer which will be invoked once changes occur.
observer.subscribe(keyState -> {
if (keyState.getKeyState().equals(KeyState.PRESSED))
return;
System.out.println("Shift released");
})