Package org.apache.pivot.wtk
Class Keyboard
- java.lang.Object
-
- org.apache.pivot.wtk.Keyboard
-
public final class Keyboard extends java.lang.Object
Class representing the system keyboard.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Keyboard.KeyCode
Contains a set of key code constants that are common to all locales.static class
Keyboard.KeyLocation
Enumeration representing key locations.static class
Keyboard.KeyStroke
Represents a keystroke, a combination of a keycode and modifier flags.static class
Keyboard.Modifier
Enumeration representing keyboard modifiers.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
areAllPressed(Set<Keyboard.Modifier> modifierSet)
Are all of the given set ofKeyboard.Modifier
s pressed?static boolean
areAllPressed(Keyboard.Modifier... modifiers)
Are all of the given list ofKeyboard.Modifier
s pressed?static boolean
areAnyPressed(Set<Keyboard.Modifier> modifierSet)
Are any of the given set ofKeyboard.Modifier
s pressed?static boolean
areAnyPressed(Keyboard.Modifier... modifiers)
Are any of the given list ofKeyboard.Modifier
s pressed?static boolean
arePressed(Set<Keyboard.Modifier> modifierSet)
Test to see if and only if the given set of modifier(s) are pressed.static boolean
arePressed(Keyboard.Modifier... modifiers)
Test to see if and only if the given modifier(s) are pressed.static DropAction
getDropAction()
Returns the current drop action.static int
getModifiers()
static boolean
isCmdPressed()
Shortcut method to test if thePlatform.getCommandModifier()
is pressed.static boolean
isPressed(Keyboard.Modifier modifier)
Tests the pressed state of a modifier.protected static void
setModifiers(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:
true
if 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:
true
if 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:
true
if only those modifiers (and no others) are pressed.
-
areAnyPressed
public static boolean areAnyPressed(Set<Keyboard.Modifier> modifierSet)
Are any of the given set ofKeyboard.Modifier
s pressed?- Parameters:
modifierSet
- The set of modifiers to test.- Returns:
true
if any of them are pressed,false
if none are pressed.
-
areAnyPressed
public static boolean areAnyPressed(Keyboard.Modifier... modifiers)
Are any of the given list ofKeyboard.Modifier
s pressed?- Parameters:
modifiers
- The modifiers to test.- Returns:
true
if any of them are pressed,false
if none are pressed.
-
areAllPressed
public static boolean areAllPressed(Set<Keyboard.Modifier> modifierSet)
Are all of the given set ofKeyboard.Modifier
s pressed?This is typically used to test two modifiers (like CTRL and SHIFT).
- Parameters:
modifierSet
- The set of modifiers to test.- Returns:
true
if all of the modifiers are pressed,false
if only some or none are pressed.
-
areAllPressed
public static boolean areAllPressed(Keyboard.Modifier... modifiers)
Are all of the given list ofKeyboard.Modifier
s pressed?This is typically used to test two modifiers (like CTRL and SHIFT).
- Parameters:
modifiers
- The modifiers to test.- Returns:
true
if all of the modifiers are pressed,false
if 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)
-
-