public final class KeyPressInfo extends Object
Information about a key (from the keyboard) to press.
Examples:
Specify that 'CTRL' + 'C' should be pressed:
// import static org.assertj.swing.fixture.KeyPressInfo.*; KeyPressInfo i = key(VK_C).modifiers(CTRL_MASK);
Specify that 'SHIFT' + 'R' should be pressed:
// import static org.assertj.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()
.
Modifier and Type | Method and Description |
---|---|
int |
keyCode() |
static KeyPressInfo |
keyCode(int keyCode)
Specifies the code of the key to press, without any modifiers (e.g.
|
int[] |
modifiers() |
KeyPressInfo |
modifiers(int... newModifiers)
Specifies the modifiers to use when pressing
the specified key (e.g. |
@Nonnull public static KeyPressInfo keyCode(int keyCode)
java.awt.event.KeyEvent.VK_C
).keyCode
- the code of the key to press.KeyPressInfo
.public int keyCode()
@Nonnull public int[] modifiers()
the specified key
.@Nonnull public KeyPressInfo modifiers(@Nonnull int... newModifiers)
Specifies the modifiers to use when pressing the specified key
(e.g.
java.awt.Event.CTRL_MASK
).
For platform-safe mask pressing (e.g. 'Control' in Windows or 'Command' in MacOS) use
Platform.controlOrCommandMask()
.
newModifiers
- the new modifiers to use.NullPointerException
- if newModifiers
is null
.Copyright © 2014–2019 AssertJ. All rights reserved.