Class KeyboardService


  • public class KeyboardService
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      KeyboardService()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void enter()
      Simulates pressing the Enter key.
      void holdShift()
      Simulates holding the Shift key using a KEY_PRESSED event.
      void keyHold​(int key)
      Simulates holding down a key using a KEY_PRESSED event.
      void keyPress​(char key)
      Simulates pressing a single character using a KEY_TYPED event.
      void keyPress​(int key)
      Simulates pressing and releasing a key in quick succession.
      void keyRelease​(int key)
      Simulates releasing a key using a KEY_RELEASED event.
      void releaseShift()
      Simulates releasing the Shift key using a KEY_RELEASED event.
      void typeChar​(char c)
      Types a single character.
      void typeString​(java.lang.String word)
      Types out a string character-by-character using KEY_TYPED events.
      void typeString​(java.lang.String text, int minSleep, int maxSleep)
      Types a string with a customizable sleep between characters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KeyboardService

        public KeyboardService()
    • Method Detail

      • typeChar

        public void typeChar​(char c)
        Types a single character. Useful for things like Bank Pins where you want control over the timing between digits.
        Parameters:
        c - the character to type
      • typeString

        public void typeString​(java.lang.String text,
                               int minSleep,
                               int maxSleep)
        Types a string with a customizable sleep between characters.
        Parameters:
        text - the string to type
        minSleep - The minimum the thread should be slept between key strokes
        maxSleep - The max the thread should be slept between key strokes
      • typeString

        public void typeString​(java.lang.String word)
        Types out a string character-by-character using KEY_TYPED events. Each character is sent with a short randomized delay and sleep between characters.
        Parameters:
        word - the string to type into the game
      • keyPress

        public void keyPress​(char key)
        Simulates pressing a single character using a KEY_TYPED event.
        Parameters:
        key - the character to press
      • holdShift

        public void holdShift()
        Simulates holding the Shift key using a KEY_PRESSED event.
      • releaseShift

        public void releaseShift()
        Simulates releasing the Shift key using a KEY_RELEASED event.
      • keyHold

        public void keyHold​(int key)
        Simulates holding down a key using a KEY_PRESSED event.
        Parameters:
        key - the key code from KeyEvent
      • keyRelease

        public void keyRelease​(int key)
        Simulates releasing a key using a KEY_RELEASED event.
        Parameters:
        key - the key code from KeyEvent
      • keyPress

        public void keyPress​(int key)
        Simulates pressing and releasing a key in quick succession.
        Parameters:
        key - the key code from KeyEvent
      • enter

        public void enter()
        Simulates pressing the Enter key. If the player is not logged in, this uses KEY_TYPED to avoid auto-login triggers.