Java Code Examples for java.awt.event.KeyEvent#VK_META

The following examples show how to use java.awt.event.KeyEvent#VK_META . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesktopToolWindowManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static boolean areAllModifiersPressed(@JdkConstants.InputEventMask int modifiers, Set<Integer> modifierCodes) {
  int mask = 0;
  for (Integer each : modifierCodes) {
    if (each == KeyEvent.VK_SHIFT) {
      mask |= InputEvent.SHIFT_MASK;
    }

    if (each == KeyEvent.VK_CONTROL) {
      mask |= InputEvent.CTRL_MASK;
    }

    if (each == KeyEvent.VK_META) {
      mask |= InputEvent.META_MASK;
    }

    if (each == KeyEvent.VK_ALT) {
      mask |= InputEvent.ALT_MASK;
    }
  }

  return (modifiers ^ mask) == 0;
}
 
Example 2
Source File: KeyMaskTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {

    keyPressReceived = true;

    int code = e.getKeyCode();

    assertEQ(code, keyCode, "wrong key code");

    int mask = 0;

    if (code == KeyEvent.VK_SHIFT) {
        mask = InputEvent.SHIFT_MASK;
    } else if (code == KeyEvent.VK_CONTROL) {
        mask = InputEvent.CTRL_MASK;
    } else if (code == KeyEvent.VK_ALT) {
        mask = InputEvent.ALT_MASK;
    } else if (code == KeyEvent.VK_META) {
        mask = InputEvent.META_MASK;
    }

    int mod = e.getModifiers() & mask;
    assertEQ(mod, mask, "invalid key mask");

    synchronized (lock) { lock.notifyAll(); }
}
 
Example 3
Source File: KeyShortCutEditPanel.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
private void textFieldKeyCodeKeyPressed(java.awt.event.KeyEvent evt) {
  if (this.buttonEditKeyCode.isSelected()) {
    switch (evt.getKeyCode()) {
      case KeyEvent.VK_META:
      case KeyEvent.VK_ALT:
      case KeyEvent.VK_SHIFT:
      case KeyEvent.VK_CONTROL:
        evt.consume();
        break;
      default: {
        updateCurrentSelectedForKey(evt);
        this.buttonEditKeyCode.setSelected(false);
        this.tableKeyShortcuts.requestFocus();
      }
      break;
    }
  }
  evt.consume();
}
 
Example 4
Source File: KeyShortCutEditPanel.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
private void textFieldKeyCodeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textFieldKeyCodeKeyPressed
  if (this.buttonEditKeyCode.isSelected()){
    switch(evt.getKeyCode()){
      case KeyEvent.VK_META:
      case KeyEvent.VK_ALT:
      case KeyEvent.VK_SHIFT:
      case KeyEvent.VK_CONTROL: evt.consume();break;
      default:{
        updateCurrentSelectedForKey(evt);
        this.buttonEditKeyCode.setSelected(false);
        this.tableKeyShortcuts.requestFocus();
      }break;
    }
  }
  evt.consume();
}
 
Example 5
Source File: WSRecorder.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void recordRawKeyEvent(RComponent r, KeyEvent e) {
    JSONObject event = new JSONObject();
    event.put("type", "key_raw");
    int keyCode = e.getKeyCode();
    if (keyCode == KeyEvent.VK_META || keyCode == KeyEvent.VK_SHIFT || keyCode == KeyEvent.VK_ALT
            || keyCode == KeyEvent.VK_CONTROL) {
        return;
    }
    if ((e.isActionKey() || e.isControlDown() || e.isMetaDown() || e.isAltDown()) && e.getID() == KeyEvent.KEY_PRESSED) {
        String mtext = buildModifiersText(e);
        event.put("modifiersEx", mtext);
        KeysMap keysMap = KeysMap.findMap(e.getKeyCode());
        if (keysMap == KeysMap.NULL) {
            return;
        }
        String keyText;
        if (keysMap == null) {
            keyText = KeyEvent.getKeyText(e.getKeyCode());
        } else {
            keyText = keysMap.toString();
        }
        event.put("keyCode", keyText);
    } else if (e.getID() == KeyEvent.KEY_TYPED && !e.isControlDown()) {
        if (Character.isISOControl(e.getKeyChar()) && hasMapping(e.getKeyChar())) {
            event.put("keyChar", getMapping(e.getKeyChar()));
        } else {
            event.put("keyChar", "" + e.getKeyChar());
        }
    } else {
        return;
    }
    recordEvent(r, event);
}
 
Example 6
Source File: ModifierTracker.java    From pumpernickel with MIT License 5 votes vote down vote up
private void key(int code, boolean pressed) {
	if (code == KeyEvent.VK_ALT) {
		if (alt != pressed) {
			alt = pressed;
			fireAltChangeListeners();
		}
	} else if (code == KeyEvent.VK_ALT_GRAPH) {
		if (altGraph != pressed) {
			altGraph = pressed;
			fireAltGraphChangeListeners();
		}
	} else if (code == KeyEvent.VK_CONTROL) {
		if (ctrl != pressed) {
			ctrl = pressed;
			fireControlChangeListeners();
		}
	} else if (code == KeyEvent.VK_META) {
		if (meta != pressed) {
			meta = pressed;
			fireMetaChangeListeners();
		}
	} else if (code == KeyEvent.VK_SHIFT) {
		if (shift != pressed) {
			shift = pressed;
			fireShiftChangeListeners();
		}
	}
}
 
Example 7
Source File: CompletionProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void processModifier(KeyEvent e) {
  final int code = e.getKeyCode();
  if (code == KeyEvent.VK_CONTROL || code == KeyEvent.VK_META || code == KeyEvent.VK_ALT || code == KeyEvent.VK_SHIFT) {
    myContentComponent.removeKeyListener(this);
    final CompletionPhase phase = CompletionServiceImpl.getCompletionPhase();
    if (phase instanceof CompletionPhase.BgCalculation) {
      ((CompletionPhase.BgCalculation)phase).modifiersChanged = true;
    }
    else if (phase instanceof CompletionPhase.InsertedSingleItem) {
      CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    }
  }
}
 
Example 8
Source File: PopupManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override void keyPressed(KeyEvent e){
    if (e != null && popup != null && popup.isShowing()) {
        
        // get popup's registered keyboard actions
        ActionMap am = popup.getActionMap();
        InputMap  im = popup.getInputMap();
        
        // check whether popup registers keystroke
        KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e);
        Object obj = im.get(ks);
        LOG.log(Level.FINE, "Keystroke for event {0}: {1}; action-map-key={2}", new Object [] { e, ks, obj }); //NOI18N
        if (shouldPopupReceiveForwardedKeyboardAction(obj)) {
            // if yes, gets the popup's action for this keystroke, perform it 
            // and consume key event
            Action action = am.get(obj);
            LOG.log(Level.FINE, "Popup component''s action: {0}, {1}", new Object [] { action, action != null ? action.getValue(Action.NAME) : null }); //NOI18N

            /* Make sure to use the popup as the source of the action, since the popup is
            also providing the event. Not doing this, and instead invoking actionPerformed
            with a null ActionEvent, was one part of the problem seen in NETBEANS-403. */
            if (SwingUtilities.notifyAction(action, ks, e, popup, e.getModifiers())) {
              e.consume();
              return;
            }
        }

        if (e.getKeyCode() != KeyEvent.VK_CONTROL &&
            e.getKeyCode() != KeyEvent.VK_SHIFT &&
            e.getKeyCode() != KeyEvent.VK_ALT &&
            e.getKeyCode() != KeyEvent.VK_ALT_GRAPH &&
            e.getKeyCode() != KeyEvent.VK_META
        ) {
            // hide tooltip if any was shown
            Utilities.getEditorUI(textComponent).getToolTipSupport().setToolTipVisible(false);
        }
    }
}
 
Example 9
Source File: KeyGestureState.java    From consulo with Apache License 2.0 5 votes vote down vote up
boolean isPureModifierEvent(int eventType) {
  final KeyEvent event = myContext.keyToProcess;
  if (event.getID() != eventType) return false;

  return event.getKeyCode() == KeyEvent.VK_CONTROL
      || event.getKeyCode() == KeyEvent.VK_ALT
      || event.getKeyCode() == KeyEvent.VK_SHIFT
      || event.getKeyCode() == KeyEvent.VK_META;
}
 
Example 10
Source File: SearchResultRender.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static String getKeyStrokeAsText (KeyStroke keyStroke) {
    if (keyStroke == null)
        return "";
    int modifiers = keyStroke.getModifiers ();
    StringBuffer sb = new StringBuffer ();
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0)
        sb.append ("Ctrl+");
    if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0)
        sb.append ("Alt+");
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0)
        sb.append ("Shift+");
    if ((modifiers & InputEvent.META_DOWN_MASK) > 0)
        if (Utilities.isMac()) {
            // Mac cloverleaf symbol
            sb.append ("\u2318+");
        } else if (isSolaris()) {
            // Sun meta symbol
            sb.append ("\u25C6+");
        } else {
            sb.append ("Meta+");
        }
    if (keyStroke.getKeyCode () != KeyEvent.VK_SHIFT &&
        keyStroke.getKeyCode () != KeyEvent.VK_CONTROL &&
        keyStroke.getKeyCode () != KeyEvent.VK_META &&
        keyStroke.getKeyCode () != KeyEvent.VK_ALT &&
        keyStroke.getKeyCode () != KeyEvent.VK_ALT_GRAPH
    )
        sb.append (Utilities.keyToString (
            KeyStroke.getKeyStroke (keyStroke.getKeyCode (), 0)
        ));
    return sb.toString ();
}
 
Example 11
Source File: KeyStrokeUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Get human-readable name for a {@link KeyStroke}.
 */
public static String getKeyStrokeAsText(@NonNull KeyStroke keyStroke) {
    int modifiers = keyStroke.getModifiers ();
    StringBuilder sb = new StringBuilder ();
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
        sb.append(EMACS_CTRL);
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
        sb.append(STRING_ALT);
    }
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
        sb.append (EMACS_SHIFT);
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
        sb.append(STRING_META);
    }
    if (keyStroke.getKeyCode () != KeyEvent.VK_SHIFT &&
        keyStroke.getKeyCode () != KeyEvent.VK_CONTROL &&
        keyStroke.getKeyCode () != KeyEvent.VK_META &&
        keyStroke.getKeyCode () != KeyEvent.VK_ALT &&
        keyStroke.getKeyCode () != KeyEvent.VK_ALT_GRAPH) {
        sb.append (Utilities.keyToString (
            KeyStroke.getKeyStroke (keyStroke.getKeyCode (), 0)
        ));
    }
    return sb.toString ();
}
 
Example 12
Source File: InstantRefactoringPerformer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static String getKeyStrokeAsText(KeyStroke keyStroke) {
    int modifiers = keyStroke.getModifiers();
    StringBuilder sb = new StringBuilder();
    sb.append('\'');
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
        sb.append("Ctrl+"); //NOI18N
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
        sb.append("Alt+"); //NOI18N
    }
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
        sb.append("Shift+"); //NOI18N
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
        sb.append("Meta+"); //NOI18N
    }
    if (keyStroke.getKeyCode() != KeyEvent.VK_SHIFT
            && keyStroke.getKeyCode() != KeyEvent.VK_CONTROL
            && keyStroke.getKeyCode() != KeyEvent.VK_META
            && keyStroke.getKeyCode() != KeyEvent.VK_ALT
            && keyStroke.getKeyCode() != KeyEvent.VK_ALT_GRAPH) {
        sb.append(org.openide.util.Utilities.keyToString(
                KeyStroke.getKeyStroke(keyStroke.getKeyCode(), 0)
        ));
    }
    sb.append('\'');
    return sb.toString();
}
 
Example 13
Source File: KeyStrokeParser.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private int getModifier(int keycode) {
    switch (keycode) {
    case KeyEvent.VK_SHIFT:
        return InputEvent.SHIFT_MASK;
    case KeyEvent.VK_CONTROL:
        return InputEvent.CTRL_MASK;
    case KeyEvent.VK_ALT:
        return InputEvent.ALT_MASK;
    case KeyEvent.VK_META:
        return InputEvent.META_MASK;
    default:
        throw new RuntimeException(OSUtils.keyEventGetKeyText(keycode) + " is not a valid modifier");
    }
}
 
Example 14
Source File: Key.java    From SikuliX1 with MIT License 5 votes vote down vote up
/**
 * HotKey modifier to be used with Sikuli's HotKey feature
 * @return META(CMD) on Mac, CTRL otherwise
 */
public static int getHotkeyModifier() {
   if (Settings.isMac()) {
     return KeyEvent.VK_META;
   } else {
     return KeyEvent.VK_CONTROL;
   }
 }
 
Example 15
Source File: DefaultInputHandler.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Handle a key pressed event. This will look up the binding for the key stroke and execute it.
 */
@Override
@SuppressWarnings("unchecked")
public void keyPressed(KeyEvent evt) {
	int keyCode = evt.getKeyCode();
	int modifiers = evt.getModifiers();

	if (keyCode == KeyEvent.VK_CONTROL || keyCode == KeyEvent.VK_SHIFT || keyCode == KeyEvent.VK_ALT
			|| keyCode == KeyEvent.VK_META) {
		return;
	}

	if ((modifiers & InputEvent.SHIFT_MASK) != 0 || (modifiers & InputEvent.CTRL_MASK) != 0 || evt.isActionKey()
			|| keyCode == KeyEvent.VK_BACK_SPACE || keyCode == KeyEvent.VK_DELETE || keyCode == KeyEvent.VK_ENTER
			|| keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_ESCAPE) {

		if (grabAction != null) {
			handleGrabAction(evt);
			return;
		}

		KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, modifiers);
		Object o = currentBindings.get(keyStroke);
		if (o == null) {
			// Don't beep if the user presses some
			// key we don't know about unless a
			// prefix is active. Otherwise it will
			// beep when caps lock is pressed, etc.
			if (currentBindings != bindings) {
				Toolkit.getDefaultToolkit().beep();
				// F10 should be passed on, but C+e F10
				// shouldn't
				repeatCount = 0;
				repeat = false;
				evt.consume();
			}
			currentBindings = bindings;
			return;
		} else if (o instanceof ActionListener) {
			currentBindings = bindings;

			executeAction((ActionListener) o, evt.getSource(), null);

			evt.consume();
			return;
		} else if (o instanceof Hashtable) {
			currentBindings = (Hashtable<KeyStroke, Object>) o;
			evt.consume();
			return;
		}
	}
}
 
Example 16
Source File: VncClientPacketSender.java    From cloudstack with Apache License 2.0 4 votes vote down vote up
private int mapAwtKeyToVncKey(int key) {
    switch (key) {
        case KeyEvent.VK_BACK_SPACE:
            return 0xff08;
        case KeyEvent.VK_TAB:
            return 0xff09;
        case KeyEvent.VK_ENTER:
            return 0xff0d;
        case KeyEvent.VK_ESCAPE:
            return 0xff1b;
        case KeyEvent.VK_INSERT:
            return 0xff63;
        case KeyEvent.VK_DELETE:
            return 0xffff;
        case KeyEvent.VK_HOME:
            return 0xff50;
        case KeyEvent.VK_END:
            return 0xff57;
        case KeyEvent.VK_PAGE_UP:
            return 0xff55;
        case KeyEvent.VK_PAGE_DOWN:
            return 0xff56;
        case KeyEvent.VK_LEFT:
            return 0xff51;
        case KeyEvent.VK_UP:
            return 0xff52;
        case KeyEvent.VK_RIGHT:
            return 0xff53;
        case KeyEvent.VK_DOWN:
            return 0xff54;
        case KeyEvent.VK_F1:
            return 0xffbe;
        case KeyEvent.VK_F2:
            return 0xffbf;
        case KeyEvent.VK_F3:
            return 0xffc0;
        case KeyEvent.VK_F4:
            return 0xffc1;
        case KeyEvent.VK_F5:
            return 0xffc2;
        case KeyEvent.VK_F6:
            return 0xffc3;
        case KeyEvent.VK_F7:
            return 0xffc4;
        case KeyEvent.VK_F8:
            return 0xffc5;
        case KeyEvent.VK_F9:
            return 0xffc6;
        case KeyEvent.VK_F10:
            return 0xffc7;
        case KeyEvent.VK_F11:
            return 0xffc8;
        case KeyEvent.VK_F12:
            return 0xffc9;
        case KeyEvent.VK_SHIFT:
            return 0xffe1;
        case KeyEvent.VK_CONTROL:
            return 0xffe3;
        case KeyEvent.VK_META:
            return 0xffe7;
        case KeyEvent.VK_ALT:
            return 0xffe9;
        case KeyEvent.VK_ALT_GRAPH:
            return 0xffea;
        case KeyEvent.VK_BACK_QUOTE:
            return 0x0060;
    }

    return key;
}
 
Example 17
Source File: TrayIconEventModifiersTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (! SystemTray.isSupported()) {
        System.out.println("SystemTray not supported on the platform under test. " +
                "Marking the test passed");
    } else {
        if (System.getProperty("os.name").toLowerCase().startsWith("win"))
            System.err.println("Test can fail if the icon hides to a tray icons pool" +
                    "in Windows 7, which is behavior by default.\n" +
                    "Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
                    "\"Always show all icons and notifications on the taskbar\" true " +
                    "to avoid this problem. Or change behavior only for Java SE tray " +
                    "icon and rerun test.");

        System.out.println(System.getProperty("os.arch"));
        if (System.getProperty("os.name").indexOf("Sun") != -1 &&
                System.getProperty("os.arch").indexOf("sparc") != -1) {
            keyTypes = new int[]{
                    KeyEvent.VK_SHIFT,
                    KeyEvent.VK_CONTROL,
                    KeyEvent.VK_META
            };

            keyNames = new String[]{
                    "SHIFT",
                    "CONTROL",
                    "META"
            };
            keyMasks = new int[]{
                    KeyEvent.SHIFT_DOWN_MASK,
                    KeyEvent.CTRL_DOWN_MASK,
                    KeyEvent.META_DOWN_MASK
            };
        }

        if (SystemTrayIconHelper.isOel7()) {
            System.out.println("OEL 7 doesn't support click modifiers in " +
                    "systray. Skipped");
            return;
        }

        new TrayIconEventModifiersTest().doTest();
    }
}
 
Example 18
Source File: StaffApplication.java    From RemoteSupportTool with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("Duplicates")
protected synchronized void doHandleKeyRelease(KeyEvent e) {
    if (handler == null) return;
    //LOGGER.debug("key released: " + e.paramString());

    // Get code of the released key.
    // Keypad arrows are translated to regular arrow keys.
    final int keyCode;
    switch (e.getKeyCode()) {
        case KeyEvent.VK_KP_DOWN:
            keyCode = KeyEvent.VK_DOWN;
            break;
        case KeyEvent.VK_KP_LEFT:
            keyCode = KeyEvent.VK_LEFT;
            break;
        case KeyEvent.VK_KP_RIGHT:
            keyCode = KeyEvent.VK_RIGHT;
            break;
        case KeyEvent.VK_KP_UP:
            keyCode = KeyEvent.VK_UP;
            break;
        default:
            keyCode = e.getKeyCode();
            break;
    }

    // Never press undefined key codes.
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return;
    }

    // Never send caps lock, num lock and scroll lock key.
    if (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK || keyCode == KeyEvent.VK_SCROLL_LOCK) {
        return;
    }

    // Detect, if a control key was pressed.
    final boolean isControlKey = e.isActionKey() ||
            keyCode == KeyEvent.VK_BACK_SPACE ||
            keyCode == KeyEvent.VK_DELETE ||
            keyCode == KeyEvent.VK_ENTER ||
            keyCode == KeyEvent.VK_SPACE ||
            keyCode == KeyEvent.VK_TAB ||
            keyCode == KeyEvent.VK_ESCAPE ||
            keyCode == KeyEvent.VK_ALT ||
            keyCode == KeyEvent.VK_ALT_GRAPH ||
            keyCode == KeyEvent.VK_CONTROL ||
            keyCode == KeyEvent.VK_SHIFT ||
            keyCode == KeyEvent.VK_META;

    // Release control keys.
    if (isControlKey) {
        //LOGGER.debug("release key \"{}\" ({})", keyCode, KeyEvent.getKeyText(keyCode));
        handler.sendKeyRelease(keyCode);
        e.consume();
    }

    // Release other keys, if they are pressed together with a modifier key.
    else if (e.isControlDown() || e.isMetaDown() || windowsKeyDown || (!SystemUtils.IS_OS_MAC && e.isAltDown()) || pressedKeys.contains(keyCode)) {
        //LOGGER.debug("release key \"{}\" ({})", keyCode, KeyEvent.getKeyText(keyCode));
        handler.sendKeyRelease(keyCode);
        pressedKeys.remove((Integer) keyCode);
        e.consume();
    }

    // Forget, that the Windows key is pressed.
    if (keyCode == KeyEvent.VK_WINDOWS) {
        synchronized (Frame.this) {
            windowsKeyDown = false;
        }
    }
}
 
Example 19
Source File: OSUtils.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public static String keyEventGetKeyText(int keycode) {
    if (keycode == KeyEvent.VK_TAB) {
        return "Tab";
    }
    if (keycode == KeyEvent.VK_CONTROL) {
        return "Ctrl";
    }
    if (keycode == KeyEvent.VK_ALT) {
        return "Alt";
    }
    if (keycode == KeyEvent.VK_SHIFT) {
        return "Shift";
    }
    if (keycode == KeyEvent.VK_META) {
        return "Meta";
    }
    if (keycode == KeyEvent.VK_SPACE) {
        return "Space";
    }
    if (keycode == KeyEvent.VK_BACK_SPACE) {
        return "Backspace";
    }
    if (keycode == KeyEvent.VK_HOME) {
        return "Home";
    }
    if (keycode == KeyEvent.VK_END) {
        return "End";
    }
    if (keycode == KeyEvent.VK_DELETE) {
        return "Delete";
    }
    if (keycode == KeyEvent.VK_PAGE_UP) {
        return "Pageup";
    }
    if (keycode == KeyEvent.VK_PAGE_DOWN) {
        return "Pagedown";
    }
    if (keycode == KeyEvent.VK_UP) {
        return "Up";
    }
    if (keycode == KeyEvent.VK_DOWN) {
        return "Down";
    }
    if (keycode == KeyEvent.VK_LEFT) {
        return "Left";
    }
    if (keycode == KeyEvent.VK_RIGHT) {
        return "Right";
    }
    if (keycode == KeyEvent.VK_ENTER) {
        return "Enter";
    }
    return KeyEvent.getKeyText(keycode);
}
 
Example 20
Source File: JavaRecorderHook.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public static String keyEventGetKeyText(int keycode) {
    if (keycode == KeyEvent.VK_TAB) {
        return "Tab";
    }
    if (keycode == KeyEvent.VK_CONTROL) {
        return "Ctrl";
    }
    if (keycode == KeyEvent.VK_ALT) {
        return "Alt";
    }
    if (keycode == KeyEvent.VK_SHIFT) {
        return "Shift";
    }
    if (keycode == KeyEvent.VK_META) {
        return "Meta";
    }
    if (keycode == KeyEvent.VK_SPACE) {
        return "Space";
    }
    if (keycode == KeyEvent.VK_BACK_SPACE) {
        return "Backspace";
    }
    if (keycode == KeyEvent.VK_HOME) {
        return "Home";
    }
    if (keycode == KeyEvent.VK_END) {
        return "End";
    }
    if (keycode == KeyEvent.VK_DELETE) {
        return "Delete";
    }
    if (keycode == KeyEvent.VK_PAGE_UP) {
        return "Pageup";
    }
    if (keycode == KeyEvent.VK_PAGE_DOWN) {
        return "Pagedown";
    }
    if (keycode == KeyEvent.VK_UP) {
        return "Up";
    }
    if (keycode == KeyEvent.VK_DOWN) {
        return "Down";
    }
    if (keycode == KeyEvent.VK_LEFT) {
        return "Left";
    }
    if (keycode == KeyEvent.VK_RIGHT) {
        return "Right";
    }
    if (keycode == KeyEvent.VK_ENTER) {
        return "Enter";
    }
    return KeyEvent.getKeyText(keycode);
}