當前位置: 首頁>>代碼示例>>Java>>正文


Java NativeKeyEvent.CTRL_MASK屬性代碼示例

本文整理匯總了Java中org.jnativehook.keyboard.NativeKeyEvent.CTRL_MASK屬性的典型用法代碼示例。如果您正苦於以下問題:Java NativeKeyEvent.CTRL_MASK屬性的具體用法?Java NativeKeyEvent.CTRL_MASK怎麽用?Java NativeKeyEvent.CTRL_MASK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.jnativehook.keyboard.NativeKeyEvent的用法示例。


在下文中一共展示了NativeKeyEvent.CTRL_MASK屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: nativeMouseReleased

@Override
public void nativeMouseReleased(NativeMouseEvent nativeEvent) {	
	// check if ctrl is pressed
	isCtrlKeyPressed = (nativeEvent.getModifiers() & NativeKeyEvent.CTRL_MASK) > 0;
	isAltKeyPressed = (nativeEvent.getModifiers() & NativeKeyEvent.ALT_MASK) > 0;
	popOverUI.hidePopOver();
}
 
開發者ID:michaelnetter,項目名稱:dracoon-dropzone,代碼行數:7,代碼來源:DropzonePopOver.java

示例2: evaluateKeyEvent

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;
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:7,代碼來源:GlobalKeyListener.java

示例3: nativeKeyPressed

public void nativeKeyPressed(NativeKeyEvent e) {

			boolean isMetaPressed = (e.getModifiers() & NativeKeyEvent.META_MASK) > 0;
			boolean isAltPressed = (e.getModifiers() & NativeKeyEvent.ALT_MASK) > 0;
			boolean isShiftPressed = (e.getModifiers() & NativeKeyEvent.SHIFT_MASK) > 0;
			boolean isCtrlPressed = (e.getModifiers() & NativeKeyEvent.CTRL_MASK) > 0;

			if(isWindows()){		        
		        
				// ALT+SHIFT+2
				if (e.getKeyCode() == NativeKeyEvent.VK_2 && isShiftPressed && isAltPressed){                	
					logger.trace("ALT+SHIFT+2 is pressed");
					startRecording();
				}

				// ALTL+SHIFT+ESC
				if (e.getKeyCode() == NativeKeyEvent.VK_ESCAPE && isShiftPressed && isAltPressed){
					logger.trace("ALT+SHIFT+ESC is pressed");
					GlobalScreen.unregisterNativeHook();
					escapeSignal.countDown();
				}

		    }
			else{
				// CTRL+SHIFT+2
				if (e.getKeyCode() == NativeKeyEvent.VK_2 && isShiftPressed && isCtrlPressed){                	
					logger.trace("CTRL+SHIFT+2 is pressed");
					startRecording();
				}

				// CTRL+SHIFT+ESC
				if (e.getKeyCode() == NativeKeyEvent.VK_ESCAPE && isShiftPressed && isCtrlPressed){
					logger.trace("CTRL+SHIFT+ESC is pressed");
					GlobalScreen.unregisterNativeHook();
					escapeSignal.countDown();
				}
			}

		}
 
開發者ID:sikuli,項目名稱:sikuli-slides,代碼行數:39,代碼來源:Recorder.java

示例4: nativeKeyPressed

@SuppressWarnings("deprecation")
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
	if (hotkeyIsPressed) {
		return; // Do nothing if Hotkey is already pressed.
	}
	int modifiers = e.getModifiers();
    if (modifiers == 0)
    	return; // Do nothing when no modifiers are pressed, because it's not a hotkey.
    boolean isAltPressed = (modifiers & NativeKeyEvent.ALT_MASK) != 0;
    boolean isShiftPressed = (modifiers & NativeKeyEvent.SHIFT_MASK) != 0;
    // Shortcut modifier is Control modifier in Windows/Linux system and Meta (Command) in
    // Mac systems.
	boolean isShortcutPressed = (modifiers & NativeKeyEvent.CTRL_MASK)
			+ (modifiers & NativeKeyEvent.META_MASK) != 0;
	for (Entry<Hotkey, ObjectProperty<KeyCodeCombination>> entry : registeredHotkeys
			.entrySet()) {
		KeyCodeCombination kcc = entry.getValue().get();
		if (kcc == null)
			continue; // Do nothing if KeyCodeCombination is not set for this Hotkey.
		// FIXME: provide compatibility with Java 9 (pretty easy).
		if (e.getRawCode() != kcc.getCode().impl_getCode())
			continue; // Key code does not match Hotkey.
		if (isAltPressed != (kcc.getAlt() == ModifierValue.DOWN))
			continue; // Alt modifier doesn't match Hotkey.
		if (isShiftPressed != (kcc.getShift() == ModifierValue.DOWN))
			continue; // Shift modifier doesn't match Hotkey.
		if (isShortcutPressed != (kcc.getShortcut() == ModifierValue.DOWN))
			continue; // Shortcut modifier doesn't match Hotkey.
		if (hotkeyIsRunning) {
			logger.error("Previously pressed Hotkey is still running.");
			return; // Do nothing if Hotkey is still running.
		}
		// At this point the pressed key and modifiers match one of the registered Hotkeys.
		// Let's run the associated runnable with this Hotkey.
		Hotkey hotkey = entry.getKey();
		logger.info("Catched the Hotkey: \"" + hotkey.name()
				+ "\". Running the associated action.");
		hotkeyIsPressed = true;
		hotkeyIsRunning = true;
		Runnable task = () -> {
			hotkey.run();
			logger.info("Finished running the action associated with the Hotkey: \""
					+ hotkey.name() + "\".");
			hotkeyIsRunning = false;
		};
		new Thread(task).start();
		break;
	}
}
 
開發者ID:ubershy,項目名稱:StreamSis,代碼行數:50,代碼來源:HotkeyManager.java

示例5: isCtrlPressed

boolean isCtrlPressed(NativeKeyEvent e){
	return (e.getModifiers() & NativeKeyEvent.CTRL_MASK) > 0;
}
 
開發者ID:sikuli,項目名稱:sikuli-slides,代碼行數:3,代碼來源:GlobalHotkeyManager.java


注:本文中的org.jnativehook.keyboard.NativeKeyEvent.CTRL_MASK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。