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


Java NativeKeyEvent類代碼示例

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


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

示例1: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
public void nativeKeyPressed(NativeKeyEvent e) {
        int code = e.getKeyCode();
        if (code == NativeKeyEvent.VC_CONTROL) {
            ctrl = true;
            for (int keycode : F_KEYS) {
                GlobalKeyConsumer.instance.consumeKeyCode(keycode);
            }
        } else if (code == NativeKeyEvent.VC_ALT) {
            if (e.getKeyLocation() == 3) { // right alt
                GlobalKeyConsumer.instance.consumeKeyCode(NativeKeyEvent.VC_C);
                ralt = true;
            } else if (e.getKeyLocation() == 2) { // left alt

            }
        }
//        log.db(e.getRawCode() + " " + code + " " + e.getKeyLocation() + " " + NativeKeyEvent.ALT_R_MASK);
        allReleased = false;
    }
 
開發者ID:rococode,項目名稱:rensa,代碼行數:19,代碼來源:GlobalKeyListener.java

示例2: handleLinuxKey

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
private void handleLinuxKey(int rawCode) {
	switch (rawCode) {
	case 65300:
		handleKeyCode(NativeKeyEvent.VC_MEDIA_PLAY);
		break;
	case 65301:
		handleKeyCode(NativeKeyEvent.VC_MEDIA_STOP);
		break;
	case 65302:
		handleKeyCode(NativeKeyEvent.VC_MEDIA_PREVIOUS);
		break;
	case 65303:
		handleKeyCode(NativeKeyEvent.VC_MEDIA_NEXT);
		break;
	}
}
 
開發者ID:Bleuzen,項目名稱:Blizcord,代碼行數:17,代碼來源:NativeKeyListener.java

示例3: handleKeyCode

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
private void handleKeyCode(int keyCode) {
	switch (keyCode) {
	case NativeKeyEvent.VC_MEDIA_PLAY:
		Log.debug("NativeKeyEvent: VC_MEDIA_PLAY");
		AudioPlayerThread.togglePause();
		break;

	case NativeKeyEvent.VC_MEDIA_STOP:
		Log.debug("NativeKeyEvent: VC_MEDIA_STOP");
		Bot.stopPlayer();
		break;

	case NativeKeyEvent.VC_MEDIA_PREVIOUS:
		Log.debug("NativeKeyEvent: VC_MEDIA_PREVIOUS");
		if(AudioPlayerThread.isPlaying()) {
			AudioPlayerThread.getMusicManager().player.getPlayingTrack().setPosition(0);
		}
		break;

	case NativeKeyEvent.VC_MEDIA_NEXT:
		Log.debug("NativeKeyEvent: VC_MEDIA_NEXT");
		AudioPlayerThread.getMusicManager().scheduler.nextTrack(1);
		break;
	}
}
 
開發者ID:Bleuzen,項目名稱:Blizcord,代碼行數:26,代碼來源:NativeKeyListener.java

示例4: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
/**
 * adds hotkey or alpha key to the repespective list if they are in the
 * valid list. prevents non valid keys from being added.
 */
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
    String temp = NativeKeyEvent.getKeyText(e.getKeyCode());
    if (validHotKeys.contains(temp)) {
        if (!pressedHotKeys.contains(temp)) {
            pressedHotKeys.add(temp);
            System.out.println(pressedHotKeys.toString());
        }
    }
    if (validAlphaKeys.contains(temp)) {
        if (!pressedAlphaKeys.contains(temp)) {
            pressedAlphaKeys.add(temp);
            System.out.println(pressedAlphaKeys.toString());
        }
    }
}
 
開發者ID:SlideKB,項目名稱:SlideBar,代碼行數:21,代碼來源:KeyHook.java

示例5: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
@Override
public void nativeKeyPressed(NativeKeyEvent e)
{
	// TODO Auto-generated method stub
	if (mode == 0 && NativeKeyEvent.getKeyText(e.getKeyCode()).matches("W"))
	{
		if (distanceset)
		{
		s = new Stopwatch();
		mode = 1;
		System.out.println("\n1st sensor triggered");
		}
		else
		{
			label.setText("Please set the distance.");
		}
	}
	if (mode == 1 && NativeKeyEvent.getKeyText(e.getKeyCode()).matches("A"))
	{
		time = s.elapsedTime();
		mode = 2;
		System.out.println("\n2nd sensor triggered");
	}
}
 
開發者ID:DrDab,項目名稱:Makey-Makey-Speedometer,代碼行數:25,代碼來源:Time.java

示例6: pressMultiKeyTest

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
@Test
public void pressMultiKeyTest() throws AWTException, InterruptedException {
	MultiKeyListener mkl = new MultiKeyListener();
	GlobalScreen.addNativeKeyListener(mkl);
	Robot robot = new Robot();
	robot.keyPress(KeyEvent.VK_CONTROL);
	robot.keyPress(KeyEvent.VK_SPACE);

	Thread.sleep(300);

	Keys pressed = mkl.getPressed();
	assertEquals(pressed.getKeys().size(), 2);
	assertTrue(pressed.getKeys().contains(new Key((char)NativeKeyEvent.VC_CONTROL_L)));
	assertTrue(pressed.getKeys().contains(new Key((char) NativeKeyEvent.VC_SPACE)));

	robot.keyRelease(KeyEvent.VK_CONTROL);
	robot.keyRelease(KeyEvent.VK_SPACE);

	assertEquals(pressed.getKeys().size(), 0);
}
 
開發者ID:niwatolli3,項目名稱:NiwaLaunchee,代碼行數:21,代碼來源:MultiKeyListenerTest.java

示例7: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
	String ss = NativeKeyEvent.getKeyText(e.getKeyCode());
	if (ss.contains("Shift")) {
		shiftState = ButtonStates.ON;
		shift = true;
		if (shiftChangeListener != null)
			shiftChangeListener.stateChanged(shiftState, shift);
	} else if (ss.contains("Control")) {
		ctrlState = ButtonStates.ON;
		ctrl = true;
		if (ctrlChangeListener != null)
			ctrlChangeListener.stateChanged(ctrlState, ctrl);
	} else if (ss.contains("Alt")) {
		altState = ButtonStates.ON;
		alt = true;
		if (altChangeListener != null)
			altChangeListener.stateChanged(altState, alt);
	}
}
 
開發者ID:alireza6677,項目名稱:JeyBoard,代碼行數:21,代碼來源:Virtualizer.java

示例8: GlobalKeyListener

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
public GlobalKeyListener() {
	m = new HashMap<Integer, Long>();

	keyPressed = new Function<NativeKeyEvent, Boolean>() {
		@Override
		public Boolean apply(NativeKeyEvent r) {
			return true;
		}
	};

	keyReleased = new Function<NativeKeyEvent, Boolean>() {
		@Override
		public Boolean apply(NativeKeyEvent r) {
			return true;
		}
	};
}
 
開發者ID:repeats,項目名稱:Repeat,代碼行數:18,代碼來源:GlobalKeyListener.java

示例9: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
@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));
            }
        }
    }
}
 
開發者ID:Exslims,項目名稱:MercuryTrade,代碼行數:23,代碼來源:MercuryNativeKeyListener.java

示例10: nativeKeyReleased

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
@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;
        }
    }
}
 
開發者ID:Exslims,項目名稱:MercuryTrade,代碼行數:21,代碼來源:MercuryNativeKeyListener.java

示例11: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:thatdude624,項目名稱:Spark-Reader,代碼行數:26,代碼來源:JNativeKeyHandler.java

示例12: nativeKeyReleased

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
@Override
public void nativeKeyReleased(NativeKeyEvent arg0) {
	if ((hash1Ready || hash2Ready)) {
		disableListener(callerBtn);

		if (callerBtn.equals(btnScreen)) {
			Main.config.setScreenKeys(newKey);
		} else if (callerBtn.equals(btnCScreen)) {
			Main.config.setCScreenKeys(newKey);
		} else if (callerBtn.equals(btnFile)) {
			Main.config.setFileKeys(newKey);
		} else if (callerBtn.equals(btnClipboard)) {
			Main.config.setClipboardKeys(newKey);
		}
		Main.st.updateKeys();
		Main.keyListener.loadKeys();
	}
}
 
開發者ID:HermexTools,項目名稱:client-legacy,代碼行數:19,代碼來源:SettingsDialog.java

示例13: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
	pressed.add(e.getRawCode());
	
	for (KeyBinding.Type k : KeyBindings.KEYBINDINGS.keySet()) {
		KeyBinding kb = KeyBindings.KEYBINDINGS.get(k);
		
		boolean trigger = false;
		for (int i : kb.getKeys()) {
			if (i != 0) {
				if (pressed.contains(i)) {
					trigger = true;
				} else {
					trigger = false;
					break;
				}
			}
		}
		
		if (trigger) {
			k.trigger();
		}
	}
}
 
開發者ID:gscrot,項目名稱:gscrot,代碼行數:25,代碼來源:KeyListener.java

示例14: addExtraKeys

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
private void addExtraKeys() {
    // Extra keys
    extraKeys.add(NativeKeyEvent.VC_DELETE);
    extraKeys.add(NativeKeyEvent.VC_INSERT);
    extraKeys.add(NativeKeyEvent.VC_HOME);
    extraKeys.add(NativeKeyEvent.VC_END);
    extraKeys.add(NativeKeyEvent.VC_PAGE_UP);
    extraKeys.add(NativeKeyEvent.VC_PAGE_DOWN);
    extraKeys.add(NativeKeyEvent.VC_ESCAPE);
    extraKeys.add(NativeKeyEvent.VC_SPACE);
    extraKeys.add(NativeKeyEvent.VC_TAB);
    extraKeys.add(NativeKeyEvent.VC_BACKSPACE);
    // Esc
    extraKeys.add(NativeKeyEvent.VC_ESCAPE);

    // Enter
    extraKeys.add(NativeKeyEvent.VC_ENTER);

    // Minus, plus, divided, multiplication
    extraKeys.add(NativeKeyEvent.VC_KP_SUBTRACT);
    extraKeys.add(NativeKeyEvent.VC_KP_ADD);
    extraKeys.add(NativeKeyEvent.VC_KP_DIVIDE);
    extraKeys.add(NativeKeyEvent.VC_KP_MULTIPLY);

}
 
開發者ID:CorpWar,項目名稱:keycast,代碼行數:26,代碼來源:DetectKeys.java

示例15: nativeKeyTyped

import org.jnativehook.keyboard.NativeKeyEvent; //導入依賴的package包/類
@Override
public void nativeKeyTyped(NativeKeyEvent e)
{
	if (hotkeyMap.isEmpty() && !isKeySelection) //not for us
		return;

	int modifiers = e.getModifiers();
	HotkeyConfiguration hotkeyConfig;

	if (isKeySelection)
	{
		hotkeyConfig = hotkeyMap.get(hotkeySelectionID);
	}
	else
	{
		String hotkeyAsStr = hotkeyToString(modifiers, lastKeycode);
		String hotkeyID = hotkeyToID.get(hotkeyAsStr);
		hotkeyConfig = hotkeyMap.get(hotkeyID);
		if (hotkeyConfig == null) //not a hotkey
			return;
	}

	hotkeyConfig.getExecutor().keyPressed(modifiers, lastKeycode, isKeySelection);

	isKeySelection = false;
}
 
開發者ID:ck3ck3,項目名稱:WhoWhatWhere,代碼行數:27,代碼來源:HotkeyManager.java


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