public class Keyboard
extends java.lang.Object
implements java.awt.event.KeyListener
Modifier and Type | Field and Description |
---|---|
static int |
ENTER_KEYCODE
KeyEvent.VK_ENTER is actually New Line, '\n'. |
Constructor and Description |
---|
Keyboard(net.runelite.api.Client client) |
Modifier and Type | Method and Description |
---|---|
void |
clickKey(char c)
Creates and sends a single KeyEvent using the given Char.
|
void |
clickKey(int keyCode)
Creates and sends a given KeyEvent using the given keyCode.
|
java.awt.Component |
getComponent() |
void |
keyPressed(java.awt.event.KeyEvent e) |
void |
keyReleased(java.awt.event.KeyEvent e) |
void |
keyTyped(java.awt.event.KeyEvent e) |
void |
pressKey(int keyCode)
Creates and sends a given PRESS KeyEvent using the given keyCode.
|
void |
releaseKey(int keyCode)
Creates and sends a given RELEASE KeyEvent using the given keyCode.
|
void |
sendKeyEvent(java.awt.event.KeyEvent e)
Actually triggers sending of a given KeyEvent in the instance of KeyListeners'
component field. |
void |
sendKeys(java.lang.String s)
Types the given String and afterwards presses Enter.
|
void |
sendKeys(java.lang.String s,
boolean enterAfter)
Types the given String and optionally presses Enter afterwards.
|
public static final int ENTER_KEYCODE
KeyEvent.VK_ENTER
is actually New Line, '\n'. The code for the Enter
button is 13. It has no associated KeyEvent
constant.public java.awt.Component getComponent()
public void sendKeys(java.lang.String s)
s
- The String to type.public void sendKeys(java.lang.String s, boolean enterAfter)
s
- The String to type.enterAfter
- True if KeyEvent.VK_ENTER
should be pressed afterwards. This is actually the '\n' character, for New Line. Useful for logging in.public void clickKey(char c)
c
- The char to send.public void clickKey(int keyCode)
Use constants where possible, from KeyEvent
, such as KeyEvent.VK_ENTER
keyCode
- The keycode to send.public void pressKey(int keyCode)
Use constants where possible, from KeyEvent
, such as KeyEvent.VK_ENTER
keyCode
- public void releaseKey(int keyCode)
Use constants where possible, from KeyEvent
, such as KeyEvent.VK_ENTER
keyCode
- public void sendKeyEvent(java.awt.event.KeyEvent e)
component
field.e
- public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener