Java Code Examples for org.jnativehook.keyboard.NativeKeyEvent#getKeyCode()
The following examples show how to use
org.jnativehook.keyboard.NativeKeyEvent#getKeyCode() .
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: MercuryNativeKeyListener.java From MercuryTrade with MIT License | 6 votes |
@Override public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) { switch (nativeKeyEvent.getKeyCode()) { case 42: { shiftPressed = true; break; } case 29: { ctrlpressed = true; break; } case 56: { menuPressed = true; break; } default: { if (!this.block) { MercuryStoreCore.hotKeySubject.onNext(this.getDescriptor(nativeKeyEvent)); } } } }
Example 2
Source File: JNativeKeyHandler.java From Spark-Reader with GNU General Public License v3.0 | 6 votes |
@Override public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) { //FIXME this is a temporary implementation //TODO use some user defined lookup table for key mappings //System.out.println("Key pressed: " + nativeKeyEvent.getKeyCode()); //this seems to do key repeats as well. Convenient switch(nativeKeyEvent.getKeyCode()) { case 30://a keyAction(KeyEvent.simMouseScrollUp); break; case 44://z keyAction(KeyEvent.simMouseScrollDown); break; case 45://x keyAction(KeyEvent.simMouseMiddle); break; case NativeKeyEvent.VC_ESCAPE: keyAction(KeyEvent.hideWindow); break; case NativeKeyEvent.VC_ENTER: keyAction(KeyEvent.advanceText); } }
Example 3
Source File: GlobalKeyListener.java From tools-ocr with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void nativeKeyPressed(NativeKeyEvent e) { if (e.getKeyCode() == NativeKeyEvent.VC_F4){ preventEvent(e); MainFm.doSnap(); } else if (e.getKeyCode() == NativeKeyEvent.VC_ESCAPE){ if (ScreenCapture.isSnapping){ preventEvent(e); MainFm.cancelSnap(); } } }
Example 4
Source File: GlobalKeyListener.java From foolqq with BSD 2-Clause "Simplified" License | 5 votes |
public void nativeKeyPressed(NativeKeyEvent e) { if (e.getKeyCode() == NativeKeyEvent.VC_ESCAPE) { try { GlobalScreen.unregisterNativeHook(); System.exit(1); } catch (NativeHookException e1) { } } }
Example 5
Source File: GlobalJNativeHookKeyListener.java From Repeat with Apache License 2.0 | 5 votes |
@Override public void nativeKeyPressed(NativeKeyEvent e) { int code = e.getKeyCode(); long time = System.currentTimeMillis(); if (keyPressed != null) { if ((!m.containsKey(code)) || (m.get(code) - time >= KEY_PRESS_DELAY_MS)) { KeyStroke stroke = JNativeHookCodeConverter.getKeyEventCode(code).press(true).at(LocalDateTime.now()); if (!keyPressed.apply(stroke.toNativeKeyEvent())) { LOGGER.warning("Internal key listener problem. Unable to apply key pressed action"); } } } m.put(code, time); }
Example 6
Source File: MercuryNativeKeyListener.java From MercuryTrade with MIT License | 5 votes |
@Override public void nativeKeyReleased(NativeKeyEvent nativeKeyEvent) { if (!this.block) { MercuryStoreCore.hotKeyReleaseSubject.onNext(this.getDescriptor(nativeKeyEvent)); } switch (nativeKeyEvent.getKeyCode()) { case 42: { shiftPressed = false; break; } case 29: { ctrlpressed = false; break; } case 56: { menuPressed = false; break; } } }
Example 7
Source File: KeyboardEventNotificator.java From DeskChan with GNU Lesser General Public License v3.0 | 4 votes |
KeyPair(NativeKeyEvent e){ keyCode = e.getKeyCode(); rawCode = e.getRawCode(); }