An InputEvent's modifiers are stored as an
int value. Each bit in the int is a flag
corresponding to a particular modifier. The corresponding values
for these flags are given as public final static ints
in the InputEvent class:
InputEvent.SHIFT_MASKInputEvent.CTRL_MASKInputEvent.META_MASKInputEvent.ALT_MASKInputEvent.BUTTON1_MASKInputEvent.BUTTON2_MASKInputEvent.BUTTON3_MASK
You can retrieve the modifiers for an event with the
getModifiers() method:
public int getModifiers()
Use the bitwise & operator to test whether a
particular flag is set. For example,
if (evt.getModifiers() & InputEvent.BUTTON2_MASK != 0) {
System.out.println("Button 2 was pressed");
}