Record Class KeyStroke
java.lang.Object
java.lang.Record
com.botwithus.bot.api.input.KeyStroke
- Record Components:
keyCode- Jagex key code,-32768..32767, orNO_KEY_CODEkeyChar- CP1252 character,0..65535, orNO_KEY_CHAR
One key event delivered to a component's key (type-10) CS2 trigger — the
argument the trigger's script reads as its key code and key character.
The engine delivers a real keystroke as two events: a key-down carrying the code with no character, then a character event carrying the character with no code. Input fields read the two halves differently, and a stroke that carries the wrong half does nothing:
- a printable character is taken from the character half, so type
it as
character(char)((-1, c)); a key-down alone appends nothing; - a control key is taken from the code half, so send
ENTER,BACKSPACEorESCAPE((code, 0)); a character 13 alone does not submit.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final KeyStrokeDeletes the character before the caret.static final intJagex key code for Backspace.static final intJagex key code for Enter.static final intJagex key code for Escape.static final KeyStrokeSubmits an input field.static final KeyStrokeCancels an input dialog.static final intkeyChar()of a stroke that carries only a key code.static final intkeyCode()of a stroke that carries only a character. -
Constructor Summary
ConstructorsConstructorDescriptionKeyStroke(int keyCode, int keyChar) Creates an instance of aKeyStrokerecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyStrokecharacter(char c) A character event typingc:(-1, c).final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intkeyChar()Returns the value of thekeyCharrecord component.intkeyCode()Returns the value of thekeyCoderecord component.static intkeyTriggerArg(int arg) The wire argument for a key trigger fired throughGameAPI.fireComponentTrigger(int, int, int, int, int), which accepts two forms.intpacked()The trigger argument this stroke travels as:(keyCode << 16) | keyChar, the code sign-carried in the high half.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
NO_KEY_CODE
-
NO_KEY_CHAR
-
CODE_ENTER
public static final int CODE_ENTERJagex key code for Enter.- See Also:
-
CODE_BACKSPACE
public static final int CODE_BACKSPACEJagex key code for Backspace.- See Also:
-
CODE_ESCAPE
public static final int CODE_ESCAPEJagex key code for Escape.- See Also:
-
ENTER
Submits an input field. -
BACKSPACE
Deletes the character before the caret. -
ESCAPE
Cancels an input dialog.
-
-
Constructor Details
-
KeyStroke
-
-
Method Details
-
character
A character event typingc:(-1, c). Printable ASCII only, because that is the range where a Javacharand the CP1252 byte the game reads are the same number; build the record directly for anything else.- Throws:
IllegalArgumentException- whencis not printable ASCII
-
keyTriggerArg
public static int keyTriggerArg(int arg) The wire argument for a key trigger fired throughGameAPI.fireComponentTrigger(int, int, int, int, int), which accepts two forms. Anargwhose high half is zero (0..0xFFFF) is a bare key code, as that method has always documented, and becomes a key-down(arg << 16) | 0. Any otherargis alreadypacked()and passes through unchanged. The two cannot be confused: the engine never produces key code0, and a character event carriesNO_KEY_CODE, so its high half is0xFFFF. -
packed
public int packed()The trigger argument this stroke travels as:(keyCode << 16) | keyChar, the code sign-carried in the high half. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
keyCode
-
keyChar
-