org.eclipse.swtbot.swt.finder.keyboard
Class Keyboard

java.lang.Object
  extended by org.eclipse.swtbot.swt.finder.keyboard.Keyboard

public class Keyboard
extends Object

Represents a Keyboard. Allows for typing keys and pressing shortcuts. Pressing shortcuts is different from pressing normal characters and 'special characters'.

NOTE: This class needs that a KeyStroke be split. This means that a single KeyStroke representing a SHIFT+T needs to be split into two KeyStrokes, one representing a SHIFT and another representing a 'T'.

Shortcut: CTRL+SHIFT+T for e.g. needs to press CTRL, SHIFT, T in that order while holding them down, and release them in the order T, SHIFT, CTRL.

Normal characters: 't' requires that you type 'T'. 'T' requires that you type the shortcut SHIFT+T.

Special characters: On a US keyboard '#' requires that you type SHIFT+3. ':' requires you to type SHIFT+;.

Version:
$Id$
Author:
Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
See Also:
Keystrokes.toKeys(int, char)

Constructor Summary
Keyboard(KeyboardStrategy strategy)
          Creates a new keyboard that uses the specified strategy to type on the keyboard.
 
Method Summary
 void pressShortcut(int modificationKeys, char c)
          Presses the shortcut specified by the given keys.
 void pressShortcut(int modificationKeys, int keyCode, char c)
          Presses the shortcut specified by the given keys.
 void pressShortcut(KeyStroke... keys)
          Presses the shortcut specified by the given keys.
 void typeCharacter(char ch)
          Types the character on the keyboard.
 void typeText(String text)
          Types the string on the keyboard.
 void typeText(String text, int interval)
          Types the string on the keyboard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Keyboard

public Keyboard(KeyboardStrategy strategy)
Creates a new keyboard that uses the specified strategy to type on the keyboard.

Parameters:
strategy - the keyboard strategy.
Method Detail

typeText

public void typeText(String text)
Types the string on the keyboard.

Parameters:
text - the text to type on the keyboard.

typeText

public void typeText(String text,
                     int interval)
Types the string on the keyboard.

Parameters:
text - the text to type on the keyboard.
interval - the interval between the keystrokes.

typeCharacter

public void typeCharacter(char ch)
Types the character on the keyboard. Note that the character may refer to multiple keystrokes.

Parameters:
ch - the character to type on the keyboard.

pressShortcut

public void pressShortcut(int modificationKeys,
                          char c)
Presses the shortcut specified by the given keys.

Parameters:
modificationKeys - the combination of SWT.ALT | SWT.CTRL | SWT.SHIFT | SWT.COMMAND.
c - the character
See Also:
Keystrokes.toKeys(int, char)

pressShortcut

public void pressShortcut(KeyStroke... keys)
Presses the shortcut specified by the given keys.

Parameters:
keys - the keys to press
See Also:
Keystrokes.toKeys(int, char)

pressShortcut

public void pressShortcut(int modificationKeys,
                          int keyCode,
                          char c)
Presses the shortcut specified by the given keys.

Parameters:
modificationKeys - the combination of SWT.ALT | SWT.CTRL | SWT.SHIFT | SWT.COMMAND.
keyCode - the keyCode, these may be special keys like F1-F12, or navigation keys like HOME, PAGE_UP
c - the character
See Also:
Keystrokes.toKeys(int, char)