Package org.apache.pivot.wtk
Class Keyboard
- java.lang.Object
-
- org.apache.pivot.wtk.Keyboard
-
public final class Keyboard extends java.lang.ObjectClass representing the system keyboard.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKeyboard.KeyCodeContains a set of key code constants that are common to all locales.static classKeyboard.KeyLocationEnumeration representing key locations.static classKeyboard.KeyStrokeRepresents a keystroke, a combination of a keycode and modifier flags.static classKeyboard.ModifierEnumeration representing keyboard modifiers.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanareAllPressed(Set<Keyboard.Modifier> modifierSet)Are all of the given set ofKeyboard.Modifiers pressed?static booleanareAllPressed(Keyboard.Modifier... modifiers)Are all of the given list ofKeyboard.Modifiers pressed?static booleanareAnyPressed(Set<Keyboard.Modifier> modifierSet)Are any of the given set ofKeyboard.Modifiers pressed?static booleanareAnyPressed(Keyboard.Modifier... modifiers)Are any of the given list ofKeyboard.Modifiers pressed?static booleanarePressed(Set<Keyboard.Modifier> modifierSet)Test to see if and only if the given set of modifier(s) are pressed.static booleanarePressed(Keyboard.Modifier... modifiers)Test to see if and only if the given modifier(s) are pressed.static DropActiongetDropAction()Returns the current drop action.static intgetModifiers()static booleanisCmdPressed()Shortcut method to test if thePlatform.getCommandModifier()is pressed.static booleanisPressed(Keyboard.Modifier modifier)Tests the pressed state of a modifier.protected static voidsetModifiers(int modifiers)Set the current set of pressed keyboard modifiers.
-
-
-
Method Detail
-
getModifiers
public static int getModifiers()
- Returns:
- A bitfield representing the keyboard modifiers that are currently pressed.
-
setModifiers
protected static void setModifiers(int modifiers)
Set the current set of pressed keyboard modifiers.- Parameters:
modifiers- The complete bit mask of current modifiers.
-
isPressed
public static boolean isPressed(Keyboard.Modifier modifier)
Tests the pressed state of a modifier.Note: this method tests whether or not one modifier is pressed. It does not, however, test if this is the ONLY modifier pressed. Use one of the
arePressed(...)methods for that purpose. To test efficiently for whether more than one modifier is pressed, use one of theareAnyPressed(...)orareAllPressed(...)methods. And finally, to succinctly test for the "Cmd" key (which is platform-dependent) being pressed, useisCmdPressed().- Parameters:
modifier- The modifier to test.- Returns:
trueif the modifier is pressed;false, otherwise.
-
arePressed
public static boolean arePressed(Set<Keyboard.Modifier> modifierSet)
Test to see if and only if the given set of modifier(s) are pressed.- Parameters:
modifierSet- The set of modifiers to test.- Returns:
trueif only those modifiers (and no others) are pressed.
-
arePressed
public static boolean arePressed(Keyboard.Modifier... modifiers)
Test to see if and only if the given modifier(s) are pressed.- Parameters:
modifiers- The modifiers to test.- Returns:
trueif only those modifiers (and no others) are pressed.
-
areAnyPressed
public static boolean areAnyPressed(Set<Keyboard.Modifier> modifierSet)
Are any of the given set ofKeyboard.Modifiers pressed?- Parameters:
modifierSet- The set of modifiers to test.- Returns:
trueif any of them are pressed,falseif none are pressed.
-
areAnyPressed
public static boolean areAnyPressed(Keyboard.Modifier... modifiers)
Are any of the given list ofKeyboard.Modifiers pressed?- Parameters:
modifiers- The modifiers to test.- Returns:
trueif any of them are pressed,falseif none are pressed.
-
areAllPressed
public static boolean areAllPressed(Set<Keyboard.Modifier> modifierSet)
Are all of the given set ofKeyboard.Modifiers pressed?This is typically used to test two modifiers (like CTRL and SHIFT).
- Parameters:
modifierSet- The set of modifiers to test.- Returns:
trueif all of the modifiers are pressed,falseif only some or none are pressed.
-
areAllPressed
public static boolean areAllPressed(Keyboard.Modifier... modifiers)
Are all of the given list ofKeyboard.Modifiers pressed?This is typically used to test two modifiers (like CTRL and SHIFT).
- Parameters:
modifiers- The modifiers to test.- Returns:
trueif all of the modifiers are pressed,falseif only some or none are pressed.
-
isCmdPressed
public static boolean isCmdPressed()
Shortcut method to test if thePlatform.getCommandModifier()is pressed.- Returns:
- The result of
isPressed(Platform.getCommandModifier()).
-
getDropAction
public static DropAction getDropAction()
Returns the current drop action.- Returns:
- The drop action corresponding to the currently pressed modifier keys.
- See Also:
DropAction.getDropAction(int)
-
-