Package org.fest.swing.core
Class KeyPressInfo
java.lang.Object
org.fest.swing.core.KeyPressInfo
Understands information about pressing a keyboard key.
Examples:
Specify that 'CTRL' + 'C' should be pressed:
// import static org.fest.swing.fixture.KeyPressInfo.*; KeyPressInfo i = key(VK_C).modifiers(CTRL_MASK);
Specify that 'SHIFT' + 'R' should be pressed:
// import static org.fest.swing.fixture.KeyPressInfo.*; KeyPressInfo i = key(VK_R).modifiers(SHIFT_MASK);
For platform-safe mask pressing (e.g. 'Control' in Windows or 'Command' in MacOS) use
.
Platform.controlOrCommandMask()
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintkeyCode()Returns the code of the key to press.static KeyPressInfokeyCode(int keyCode) Specifies the code of the key to press, without any modifiers (e.g.int[]Returns the modifiers to use when pressing.the specified keymodifiers(int... newModifiers) Specifies the modifiers to use when pressing(e.g.the specified key
-
Field Details
-
keyCode
private final int keyCode -
modifiers
private int[] modifiers
-
-
Constructor Details
-
KeyPressInfo
private KeyPressInfo(int keyCode, int[] modifiers)
-
-
Method Details
-
keyCode
Specifies the code of the key to press, without any modifiers (e.g..)KeyEvent.VK_C- Parameters:
keyCode- the code of the key to press.- Returns:
- the created
KeyPressInfo.
-
keyCode
public int keyCode()Returns the code of the key to press.- Returns:
- the code of the key to press.
-
modifiers
public int[] modifiers()Returns the modifiers to use when pressing.the specified key- Returns:
- the modifiers to use.
-
modifiers
Specifies the modifiers to use when pressing(e.g.the specified key.)Event.CTRL_MASKFor platform-safe mask pressing (e.g. 'Control' in Windows or 'Command' in MacOS) use
.Platform.controlOrCommandMask()- Parameters:
newModifiers- the new modifiers to use.- Returns:
- this object.
- Throws:
NullPointerException- ifnewModifiersisnull.
-