High Level API
Kotlin: High Level API depends on Keyboard which is a wrapper around the NativeKeyboardHandler .
Java: High Level API depends on JKeyboard .
NodeJS: High Level API depends on JsKeyboard .
Importing the package.
Adding a shortcut (Hotkey).
Kotlin
keyboard . addShortcut ( Key . LeftCtrl + Key . E , trigger = KeyState . KeyDown ) {
println ( "triggered" )
}
Note: The lambda is in suspend context, launched in context provided at time of instantiation of Keyboard (defaults to Dispatchers.Default).
NodeJS
keyboard . addShortcut ( 'LeftCtrl + E' , true ,
() => console . log ( "triggered" )
);
Java 8
Set < Key > keys = new HashSet <> ();
Collections . addAll ( keys , Key . LeftCtrl , Key . E );
keyboard . addShortcut ( new KeySet ( keys ), KeyState . KeyDown ,
() -> System . out . println ( "triggered" )
);
Java 9 or above
Set < Key > keys = Set . of ( Key . LeftCtrl , Key . E );
keyboard . addShortcut ( new KeySet ( keys ), KeyState . KeyDown ,
() -> System . out . println ( "triggered" )
);
Note: trigger
defaults to KeyState.KeyDown when not provided.
Send a KeySet to the host machine.
Write a sentence (String) on the host machine.
Wait till a KeySet is pressed.
Suspensive wait in Kotlin, whereas asynchronous CompletableFuture<>
for Java
Note: trigger
defaults to KeyState.KeyDown when not provided.
Record Key presses till specific KeySet .
Recorded KeyPresses is pushed into a KeyPressSequence (List<Duration, KeyEvent>
)
Play a recorded or created collection of Keys at defined order.
Note: speedFactor
defaults to 1.0 when not provided.