本文整理匯總了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;
}
示例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));
}
}
}
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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();
}
}
}
}
示例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();
}
}
}
示例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;
}
}
示例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;
}
}
示例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();
}
}
}
示例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);
}
}
}
示例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();
}
}
}
示例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");
});
}
}