Package org.rspeer.game
Class Keyboard
- java.lang.Object
-
- org.rspeer.game.Keyboard
-
public class Keyboard extends Object
Provides operations related to the Keyboard. Please note that this should only be used when necessary. In most cases there are better alternatives, such as invoking CS2 viaGame.ScriptExecutor
.
-
-
Constructor Summary
Constructors Constructor Description Keyboard()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
pressEnter()
Presses the Enter key.static void
pressEventKey(int eventKey)
Presses and releases a key specified by its key code.static void
sendKey(char key)
Sends a single character as keyboard input.static void
sendText(String text, boolean pressEnter)
Sends a sequence of characters as keyboard input.
-
-
-
Method Detail
-
sendText
public static void sendText(String text, boolean pressEnter)
Sends a sequence of characters as keyboard input.Each character in the provided string is dispatched as a key typed event. Optionally, the Enter key can be pressed after the input.
- Parameters:
text
- the text to send as keyboard inputpressEnter
-true
to press the Enter key after sending the text,false
otherwise- Throws:
IllegalArgumentException
- iftext
is null
-
pressEnter
public static void pressEnter()
Presses the Enter key.This method dispatches both
KEY_PRESSED
andKEY_RELEASED
events for the Enter key.
-
sendKey
public static void sendKey(char key)
Sends a single character as keyboard input.This method dispatches a
KEY_TYPED
event for the given character.- Parameters:
key
- the character to send as input
-
pressEventKey
public static void pressEventKey(int eventKey)
Presses and releases a key specified by its key code.This method dispatches both
KEY_PRESSED
andKEY_RELEASED
events for the specified key code.- Parameters:
eventKey
- the key code of the key to press
-
-