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


Java NativeKeyEvent.getKeyCode方法代碼示例

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


在下文中一共展示了NativeKeyEvent.getKeyCode方法的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: 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

示例3: 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

示例4: 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

示例5: nativeKeyReleased

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public void nativeKeyReleased(NativeKeyEvent e) {
    // If Keyboard is Active and Left Alt is released
    if ((e.getKeyCode() == NativeKeyEvent.VC_ALT_L) && (this.mode == Keyboard.KeyboardMode.ACTIVE)) {
        this.alt = false;

        // Delete the 1 or 2 stray characters
        // Alt + P will print P in computer craft, this deletes the P
        // if the user did not.
        if (!this.bspace && this.keypressed) {
            schedule.add(VK_BACK_SPACE);
        } else {
            this.bspace = false;
        }

        if (this.keypressed)
            schedule.add(VK_BACK_SPACE);
    }
}
 
開發者ID:Matt529,項目名稱:CCAutotyper,代碼行數:20,代碼來源:BaseMethodology.java

示例6: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public void nativeKeyPressed(NativeKeyEvent event) {
	if (mActiveKeys.containsKey(event.getRawCode())) {
		return;
	}

	BioKeystrokeEvent bioEvent = new BioKeystrokeEvent();

	bioEvent.press_time = event.getWhen();
	bioEvent.key_code = event.getKeyCode();
	bioEvent.key_string = NativeKeyEvent.getKeyText(event.getKeyCode()).toLowerCase().replace(' ', '_');
	bioEvent.modifier_code = event.getModifiers();
	bioEvent.modifier_name = NativeKeyEvent.getModifiersText(event.getModifiers()).toLowerCase().replace(' ', '_');
	bioEvent.key_location = event.getKeyLocation();

	mActiveKeys.put(event.getRawCode(), bioEvent);

	BioLogger.LOGGER.info("Key pressed:: key code: " + bioEvent.key_code + ", key name: " + bioEvent.key_string);
}
 
開發者ID:vmonaco,項目名稱:biologger,代碼行數:20,代碼來源:Listener.java

示例7: initHotKeys

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
private void initHotKeys() {
	GlobalHotkeyManager hotkeys = new GlobalHotkeyManager(){
		@Override
		public void nativeKeyPressed(NativeKeyEvent e) {
			if (isAltPressed(e) && isCtrlPressed(e)){
				if (e.getKeyCode() == KeyEvent.VK_RIGHT){
					invokeNext();
				}else if (e.getKeyCode() == KeyEvent.VK_LEFT){			
					invokePrevious();
				}else if (e.getKeyCode() == KeyEvent.VK_ESCAPE){
					//						quit();
				}else if (e.getKeyCode() == KeyEvent.VK_P){					 
					togglePlay();
				}else if (e.getKeyCode() == KeyEvent.VK_R){
					invokeRefresh();
				}
			}				
		}			
	};
	hotkeys.start();
}
 
開發者ID:sikuli,項目名稱:sikuli-slides,代碼行數:22,代碼來源:SlideShowViewer.java

示例8: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
	if (slideShow == null)
		return;
	
	if (isAltPressed(e) && isCtrlPressed(e)){
		if (e.getKeyCode() == KeyEvent.VK_RIGHT){
			slideShow.next();
		}else if (e.getKeyCode() == KeyEvent.VK_LEFT){			
			slideShow.previous();
		}else if (e.getKeyCode() == KeyEvent.VK_ESCAPE){
			slideShow.quit();
		}else if (e.getKeyCode() == KeyEvent.VK_P){
		 
			if (slideShow.isPaused()){
				slideShow.play();
			}else{
				slideShow.pause();
			}
		}
	}
}
 
開發者ID:sikuli,項目名稱:sikuli-slides,代碼行數:23,代碼來源:SlideShowHotkeyManager.java

示例9: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
public void nativeKeyPressed(NativeKeyEvent e) {
	if (isAltPressed(e) && isCtrlPressed(e)){
					
		if (e.getKeyCode() == KeyEvent.VK_RIGHT){
			skipCurrentAction();
			nextSlide();
		}else if (e.getKeyCode() == KeyEvent.VK_LEFT){			
			skipCurrentAction();
			prevSlide();
		}else if (e.getKeyCode() == KeyEvent.VK_ESCAPE){
			quit();
		}else if (e.getKeyCode() == KeyEvent.VK_A){
			toggleAutoAdvance();
		}
	}
	
}
 
開發者ID:sikuli,項目名稱:sikuli-slides,代碼行數:18,代碼來源:SlideShowExecutor.java

示例10: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public void nativeKeyPressed(NativeKeyEvent nativeEvent) {
	if (nativeEvent.getKeyCode() == NativeKeyEvent.VC_CONTROL) {
		isCtrlKeyPressed = true;
	}
	if (nativeEvent.getKeyCode() == NativeKeyEvent.VC_ALT) {
		isAltKeyPressed = true;
	}
}
 
開發者ID:michaelnetter,項目名稱:dracoon-dropzone,代碼行數:10,代碼來源:DropzonePopOver.java

示例11: nativeKeyReleased

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public void nativeKeyReleased(NativeKeyEvent nativeEvent) {
	if (nativeEvent.getKeyCode() == NativeKeyEvent.VC_CONTROL) {
		isCtrlKeyPressed = false;
	}
	if (nativeEvent.getKeyCode() == NativeKeyEvent.VC_ALT) {
		isAltKeyPressed = false;
	}
}
 
開發者ID:michaelnetter,項目名稱:dracoon-dropzone,代碼行數:10,代碼來源:DropzonePopOver.java

示例12: nativeKeyReleased

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
public void nativeKeyReleased(NativeKeyEvent e) {
    int code = e.getKeyCode();
    if (code == NativeKeyEvent.VC_CONTROL) {
        allReleased = true;
        ctrl = false;
        for (int keycode : F_KEYS) {
            GlobalKeyConsumer.instance.dontConsumeKeyCode(keycode);
        }
    } else if (code == NativeKeyEvent.VC_ALT) {
        if (e.getKeyLocation() == 3) { // right alt
            ralt = false;
            GlobalKeyConsumer.instance.dontConsumeKeyCode(NativeKeyEvent.VC_C);
        } else if (e.getKeyLocation() == 2) { // left alt
        }
    } else if (ctrl) {
        if (code == NativeKeyEvent.VC_F9) {
            MediaKeys.volumeDown();
        } else if (code == NativeKeyEvent.VC_F10) {
            MediaKeys.volumeUp();
        } else if (code == NativeKeyEvent.VC_F11) {
            MediaKeys.mute();
        } else if (code == NativeKeyEvent.VC_F8) {
            MediaKeys.play();
        } else if (code == NativeKeyEvent.VC_F7) {
            MediaKeys.next();
        } else if (code == NativeKeyEvent.VC_F6) {
            MediaKeys.prev();
        }
    } else if (ralt) {
        if (code == NativeKeyEvent.VC_C) {
            MouseControls.moveMouseToCorner();
        } else if (code == NativeKeyEvent.VC_X) {
            MouseControls.moveMouseToCenter();
        }
    }

}
 
開發者ID:rococode,項目名稱:rensa,代碼行數:38,代碼來源:GlobalKeyListener.java

示例13: consume

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
private void consume(NativeKeyEvent e) {
        int code = e.getKeyCode();
        if (consume.contains(code)) {
            System.out.print("Attempting to consume " + code + "[" + NativeKeyEvent.getKeyText(code) + "] event...\t");
            reflectConsume(e);
        } else if (code == NativeKeyEvent.VC_ALT) {
            if (e.getKeyLocation() == 3) { // right alt
//                log.info("Attempting to consume right alt...\t");
//                reflectConsume(e);
            }
        }
    }
 
開發者ID:rococode,項目名稱:rensa,代碼行數:13,代碼來源:GlobalKeyConsumer.java

示例14: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
    System.out.println("Key Pressed: " + NativeKeyEvent.getKeyText(e.getKeyCode()));

    if (e.getKeyCode() == NativeKeyEvent.VC_ESCAPE) {
        try {
            GlobalScreen.unregisterNativeHook();
        } catch (NativeHookException ex) {
            ex.printStackTrace();
        }
    }
}
 
開發者ID:maximova136,項目名稱:j-demo,代碼行數:13,代碼來源:Main.java

示例15: nativeKeyReleased

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public void nativeKeyReleased(NativeKeyEvent e) {
    System.out.println("Key Released: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
    if (e.getKeyCode() == NativeKeyEvent.VC_PRINTSCREEN) {
        Platform.runLater(() -> {
            captureWindowController.prepareForCapture(true);
            System.out.println("prepared for capture");
        });
    }
}
 
開發者ID:maximova136,項目名稱:j-demo,代碼行數:11,代碼來源:Main.java


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