Java Code Examples for javafx.scene.input.KeyEvent#isMetaDown()

The following examples show how to use javafx.scene.input.KeyEvent#isMetaDown() . 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: ShowPanel.java    From oim-fx with MIT License 6 votes vote down vote up
public void processKeyEvent(KeyEvent ev) {
	if (webPage == null)
		return;
	ev.consume();
	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}

	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 2
Source File: JFXKey.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static UIKeyCombination getCombination(KeyEvent keyEvent) {
	UIKeyCombination keyCombination = new UIKeyCombination();
	if( keyEvent.isAltDown() ) {
		keyCombination.getKeys().add(UIKey.ALT);
	}
	if( keyEvent.isShiftDown() ) {
		keyCombination.getKeys().add(UIKey.SHIFT);
	}
	if( keyEvent.isControlDown() ) {
		keyCombination.getKeys().add(UIKey.CONTROL);
	}
	if( keyEvent.isMetaDown() ) {
		keyCombination.getKeys().add(UIKey.COMMAND);
	}
	
	UIKey principalKey = JFXKey.getKey(keyEvent);
	if(!keyCombination.contains(principalKey)) {
		keyCombination.getKeys().add(principalKey);
	}
	
	return keyCombination;
}
 
Example 3
Source File: WebViewEventDispatcher.java    From oim-fx with MIT License 6 votes vote down vote up
private void processKeyEvent(KeyEvent ev) {
    if (page == null) return;

    String text = null;
    String keyIdentifier = null;
    int windowsVirtualKeyCode = 0;
    if(ev.getEventType() == KeyEvent.KEY_TYPED) {
        text = ev.getCharacter();
    } else {
        KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
        keyIdentifier = keyCodeEntry.getKeyIdentifier();
        windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
    }

    WCKeyEvent keyEvent = new WCKeyEvent(
            idMap.get(ev.getEventType()),
            text,
            keyIdentifier,
            windowsVirtualKeyCode,
            ev.isShiftDown(), ev.isControlDown(),
            ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
    if (page.dispatchKeyEvent(keyEvent)) {
        ev.consume();
    }
}
 
Example 4
Source File: WritePane.java    From oim-fx with MIT License 6 votes vote down vote up
private void processKeyEvent(KeyEvent ev) {
	if (webPage == null)
		return;

	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}
	System.out.println(ev.getText());
	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 5
Source File: JavaFxRecorderHook.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static String ketEventGetModifiersExText(KeyEvent event) {
    StringBuffer sb = new StringBuffer();

    if (event.isControlDown()) {
        sb.append("Ctrl+");
    }
    if (event.isMetaDown()) {
        sb.append("Meta+");
    }
    if (event.isAltDown()) {
        sb.append("Alt+");
    }
    if (event.isShiftDown()) {
        sb.append("Shift+");
    }
    String text = sb.toString();
    if (text.equals("")) {
        return text;
    }
    return text.substring(0, text.length() - 1);
}
 
Example 6
Source File: OSFXUtils.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static String ketEventGetModifiersExText(KeyEvent event) {
    StringBuffer sb = new StringBuffer();

    if (event.isControlDown()) {
        sb.append("Ctrl+");
    }
    if (event.isMetaDown()) {
        sb.append("Meta+");
    }
    if (event.isAltDown()) {
        sb.append("Alt+");
    }
    if (event.isShiftDown()) {
        sb.append("Shift+");
    }
    String text = sb.toString();
    if (text.equals("")) {
        return text;
    }
    return text.substring(0, text.length() - 1);
}
 
Example 7
Source File: EventQueueDeviceTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private static String checkModifier(KeyEvent e) {
    String s = "";
    if (e.isShiftDown()) {
        s = "Shift";
    }
    if (e.isControlDown()) {
        s = "Ctrl";
    }
    if (e.isAltDown()) {
        s = "Alt";
    }
    if (e.isMetaDown()) {
        s = "Meta";
    }
    return s;
}
 
Example 8
Source File: WSRecorder.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private String buildModifiersText(KeyEvent e) {
    StringBuilder sb = new StringBuilder();
    if (e.isAltDown()) {
        sb.append("Alt+");
    }
    if (e.isControlDown()) {
        sb.append("Ctrl+");
    }
    if (e.isMetaDown()) {
        sb.append("Meta+");
    }
    if (e.isShiftDown()) {
        sb.append("Shift+");
    }
    if (sb.length() > 0) {
        sb.setLength(sb.length() - 1);
    }
    String mtext = sb.toString();
    return mtext;
}
 
Example 9
Source File: WritePanel.java    From oim-fx with MIT License 5 votes vote down vote up
public void processKeyEvent(KeyEvent ev) {
	if (webPage == null)
		return;
	ev.consume();
	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		System.out.println(ev.getCode());
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}

	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 10
Source File: ConsoleKeyEvent.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
@Override
public void handle (KeyEvent e)                     // onKeyTyped
{
  if (e.getEventType () != KeyEvent.KEY_TYPED)
    return;
  String c = e.getCharacter ();
  if (c.isEmpty ())
    return;
  char ch = c.charAt (0);

  if (screen.isKeyboardLocked () || e.isMetaDown () || e.isControlDown ()
      || e.isAltDown ())
  {
    // seems to be a bug in java
    if (e.isMetaDown ())
    {
      if (ch == '-')                    // osx fix
      {
        screen.getFontManager ().smaller ();
        e.consume ();
      }
      else if (ch == '=')               // osx fix
      {
        screen.getFontManager ().bigger ();
        e.consume ();
      }
    }

    return;
  }

  if (ch >= 32 && ch < 0x7F)
  {
    cursor.typeChar ((byte) Dm3270Utility.asc2ebc[ch]);
    e.consume ();
  }
}
 
Example 11
Source File: ConsoleKeyEvent.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handle (KeyEvent e)                     // onKeyTyped
{
  if (e.getEventType () != KeyEvent.KEY_TYPED)
    return;
  String c = e.getCharacter ();
  if (c.isEmpty ())
    return;
  char ch = c.charAt (0);

  if (screen.isKeyboardLocked () || e.isMetaDown () || e.isControlDown ()
      || e.isAltDown ())
  {
    // seems to be a bug in java
    if (e.isMetaDown ())
    {
      if (ch == '-')                    // osx fix
      {
        screen.getFontManager ().smaller ();
        e.consume ();
      }
      else if (ch == '=')               // osx fix
      {
        screen.getFontManager ().bigger ();
        e.consume ();
      }
    }

    return;
  }

  if (ch >= 32 && ch < 0x7F)
  {
    cursor.typeChar ((byte) Dm3270Utility.asc2ebc[ch]);
    e.consume ();
  }
}
 
Example 12
Source File: ChatWritePane.java    From oim-fx with MIT License 5 votes vote down vote up
public void processKeyEvent(KeyEvent ev) {
	if (webPage == null)
		return;
	ev.consume();
	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		System.out.println(ev.getCode());
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}

	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 13
Source File: ChatShowPane.java    From oim-fx with MIT License 5 votes vote down vote up
public void processKeyEvent(KeyEvent ev) {
	if (webPage == null){
		return;
	}
	ev.consume();
	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}

	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 14
Source File: WSRecorder.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void recordRawKeyEvent(RFXComponent r, KeyEvent e) {
    JSONObject event = new JSONObject();
    event.put("type", "key_raw");
    KeyCode keyCode = e.getCode();
    if (keyCode.isModifierKey()) {
        return;
    }
    if ((keyCode.isFunctionKey() || keyCode.isArrowKey() || keyCode.isKeypadKey() || keyCode.isMediaKey()
            || keyCode.isNavigationKey() || e.isControlDown() || e.isMetaDown() || e.isAltDown()
            || needManualRecording(keyCode)) && e.getEventType() == KeyEvent.KEY_PRESSED) {
        String mtext = buildModifiersText(e);
        event.put("modifiersEx", mtext);
        KeysMap keysMap = KeysMap.findMap(e.getCode());
        if (keysMap == KeysMap.NULL) {
            return;
        }
        String keyText;
        if (keysMap == null) {
            keyText = e.getText();
        } else {
            keyText = keysMap.toString();
        }
        event.put("keyCode", keyText);
    } else if (e.getEventType() == KeyEvent.KEY_TYPED && !e.isControlDown() && !needManualRecording(keyCode)) {
        char[] cs = e.getCharacter().toCharArray();
        if (cs.length == 0) {
            return;
        }
        for (char c : cs) {
            if (Character.isISOControl(c) && hasMapping(c)) {
                event.put("keyChar", getMapping(c));
            } else {
                event.put("keyChar", "" + c);
            }
        }
    } else {
        return;
    }
    recordEvent(r, event);
}
 
Example 15
Source File: JavaFxRecorderHook.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public static boolean isModifiers(KeyEvent e) {
    if (e.isAltDown() || e.isControlDown() || e.isMetaDown() || e.isShiftDown()) {
        return true;
    }
    return false;
}
 
Example 16
Source File: OSFXUtils.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public static boolean isModifiers(KeyEvent e) {
    if (e.isAltDown() || e.isControlDown() || e.isMetaDown() || e.isShiftDown()) {
        return true;
    }
    return false;
}
 
Example 17
Source File: KeyMap.java    From FxDock with Apache License 2.0 4 votes vote down vote up
protected static KKey key(KeyEvent ev)
	{
		int flags = 0;
		KeyCode cd;
		String ch;
		
		if(ev.getEventType() == KeyEvent.KEY_PRESSED)
		{
			flags |= KEY_PRESSED;
			cd = ev.getCode();
			ch = null;
		}
		else if(ev.getEventType() == KeyEvent.KEY_RELEASED)
		{
			flags |= KEY_RELEASED;
			cd = ev.getCode();
			ch = null;
		}
		else if(ev.getEventType() == KeyEvent.KEY_TYPED)
		{
			flags |= KEY_TYPED;
			cd = null;
			ch = ev.getCharacter();
		}
		else
		{
			throw new Error("?" + ev.getEventType());
		}
		
		if(ev.isAltDown())
		{
			flags |= ALT;
		}
		
		if(ev.isControlDown())
		{
			flags |= CTRL;
		}

		if(ev.isMetaDown())
		{
			flags |= META;
		}

		if(ev.isShiftDown())
		{
			flags |= SHIFT;
		}
		
		if(ev.isShortcutDown())
		{
			flags |= ACTUAL_SHORTCUT;
		}
		
//		D.f("key event 0x%8x %s", flags, ev.getCode());
		
		return new KKey(flags, cd, ch);
	}
 
Example 18
Source File: EventHandlerTool.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public static boolean isWithoutModifier(final KeyEvent event) {
    return !(event.isAltDown() || event.isControlDown() || event.isMetaDown() || event.isShortcutDown() || event.isShiftDown());
}
 
Example 19
Source File: DragSupport.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
private boolean isModifierCorrect(KeyEvent t, KeyCode keyCode) {
    return (keyCode != KeyCode.ALT ^ t.isAltDown())
            && (keyCode != KeyCode.CONTROL ^ t.isControlDown())
            && (keyCode != KeyCode.SHIFT ^ t.isShiftDown())
            && (keyCode != KeyCode.META ^ t.isMetaDown());
}
 
Example 20
Source File: KeyButtonEventHandler.java    From jfxvnc with Apache License 2.0 4 votes vote down vote up
private static boolean isModifierPressed(KeyEvent event) {
  return event.isAltDown() || event.isControlDown() || event.isMetaDown() || event.isShortcutDown();
}