Java Code Examples for java.awt.event.KeyEvent#VK_ALT_GRAPH

The following examples show how to use java.awt.event.KeyEvent#VK_ALT_GRAPH . 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: WizardUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static String keyStrokeToString(KeyStroke keyStroke) {
    int modifiers = keyStroke.getModifiers();
    StringBuffer sb = new StringBuffer();
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
        sb.append("Ctrl+"); // NOI18N
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
        sb.append("Alt+"); // NOI18N
    }
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
        sb.append("Shift+"); // NOI18N
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
        sb.append("Meta+"); // NOI18N
    }
    if (keyStroke.getKeyCode() != KeyEvent.VK_SHIFT &&
            keyStroke.getKeyCode() != KeyEvent.VK_CONTROL &&
            keyStroke.getKeyCode() != KeyEvent.VK_META &&
            keyStroke.getKeyCode() != KeyEvent.VK_ALT &&
            keyStroke.getKeyCode() != KeyEvent.VK_ALT_GRAPH) {
        sb.append(Utilities.keyToString(
                KeyStroke.getKeyStroke(keyStroke.getKeyCode(), 0)));
    }
    return sb.toString();
}
 
Example 2
Source File: KeyGetter.java    From tn5250j with GNU General Public License v2.0 6 votes vote down vote up
void processVTKeyReleased(KeyEvent e){
         displayInfo(e);
      if (isLinux && e.getKeyCode() == KeyEvent.VK_ALT_GRAPH) {

         isAltGr = false;
      }
      int keycode = e.getKeyCode();
      if (e.isAltDown() ||
         e.isShiftDown() ||
         e.isControlDown() ||
         e.isActionKey() ||
         keycode == KeyEvent.VK_CONTROL) {


         keyevent = e;
//            displayInfo(e,"Released added");
         dialog.setVisible(false);
         dialog.dispose();
      }
  }
 
Example 3
Source File: ShortcutTextField.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void processKeyEvent(KeyEvent e) {
  if (e.getID() == KeyEvent.KEY_PRESSED) {
    int keyCode = e.getKeyCode();
    if (
            keyCode == KeyEvent.VK_SHIFT ||
            keyCode == KeyEvent.VK_ALT ||
            keyCode == KeyEvent.VK_CONTROL ||
            keyCode == KeyEvent.VK_ALT_GRAPH ||
            keyCode == KeyEvent.VK_META
            ){
      return;
    }
    setKeyStroke(KeyStrokeAdapter.getDefaultKeyStroke(e));
  }
}
 
Example 4
Source File: FilterTextField.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
private void updateFilter(KeyEvent e) {
	String filterText = getText();
	// do nothing if no actual change was done
	if (valueLastUpdate != null && valueLastUpdate.equals(filterText)) {
		return;
	}

	if ((filterText == null) || (filterText.length() == 0)) {
		if ((e == null)
				|| ((e.getKeyCode() != KeyEvent.VK_BACK_SPACE) && (e.getKeyCode() != KeyEvent.VK_DELETE)
						&& (e.getKeyCode() != KeyEvent.VK_SHIFT) && (e.getKeyCode() != KeyEvent.VK_ALT)
						&& (e.getKeyCode() != KeyEvent.VK_ALT_GRAPH) && (e.getKeyCode() != KeyEvent.VK_CONTROL)
						&& (e.getKeyCode() != KeyEvent.VK_META) && (!e.isActionKey()))) {
			setText(null);
		}
	}

	// store text when listeners were notified
	valueLastUpdate = filterText;
	for (FilterListener l : filterListeners) {
		l.valueChanged(filterText);
	}
}
 
Example 5
Source File: ShortcutListener.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void keyPressed(KeyEvent e) {
    assert (e.getSource() instanceof JTextField);

    if(((e.getModifiers() & (KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK | KeyEvent.META_MASK)) == 0) &&
            (e.getKeyCode() == KeyEvent.VK_DOWN || 
            e.getKeyCode() == KeyEvent.VK_UP ||
            e.getKeyCode() == KeyEvent.VK_ESCAPE)) {
        return ;
    }
    
    textField = (JTextField) e.getSource();
    KeyStroke keyStroke = createKeyStroke(e);

    boolean add = e.getKeyCode() != KeyEvent.VK_SHIFT &&
            e.getKeyCode() != KeyEvent.VK_CONTROL &&
            e.getKeyCode() != KeyEvent.VK_ALT &&
            e.getKeyCode() != KeyEvent.VK_META &&
            e.getKeyCode() != KeyEvent.VK_ALT_GRAPH;

    if (!(enterConfirms && keyStroke.equals(enterKS))) {
        if (keyStroke.equals(backspaceKS) && !key.equals("")) {
            // delete last key
            int i = key.lastIndexOf(' '); //NOI18N
            if (i < 0) {
                key = ""; //NOI18N
            } else {
                key = key.substring(0, i);
            }
            textField.setText(key);
        } else {
            // add key
            addKeyStroke(keyStroke, add);
        }

        e.consume();
    }
}
 
Example 6
Source File: ShortcutsDialog.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void keyPressed (KeyEvent e) {
    KeyStroke keyStroke = ShortcutListener.createKeyStroke(e);
    
    boolean add = e.getKeyCode () != KeyEvent.VK_SHIFT &&
                  e.getKeyCode () != KeyEvent.VK_CONTROL &&
                  e.getKeyCode () != KeyEvent.VK_ALT &&
                  e.getKeyCode () != KeyEvent.VK_META &&
                  e.getKeyCode () != KeyEvent.VK_ALT_GRAPH;
    
    if (keyStroke.equals (backspaceKS) && !key.equals ("")) {
        // delete last key
        int i = key.lastIndexOf (' '); //NOI18N
        if (i < 0) {
            key = ""; //NOI18N
        } else {
            key = key.substring (0, i);
        }
        getTfShortcut().setText (key);
    } else {
        // add key
        addKeyStroke (keyStroke, add);
    }
    if (add) {
        updateWarning();
    } else {
        setShortcutValid(false);
    }
    e.consume ();
}
 
Example 7
Source File: KeyStrokeUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Get human-readable name for a {@link KeyStroke}.
 */
public static String getKeyStrokeAsText(@NonNull KeyStroke keyStroke) {
    int modifiers = keyStroke.getModifiers ();
    StringBuilder sb = new StringBuilder ();
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
        sb.append(EMACS_CTRL);
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
        sb.append(STRING_ALT);
    }
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
        sb.append (EMACS_SHIFT);
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
        sb.append(STRING_META);
    }
    if (keyStroke.getKeyCode () != KeyEvent.VK_SHIFT &&
        keyStroke.getKeyCode () != KeyEvent.VK_CONTROL &&
        keyStroke.getKeyCode () != KeyEvent.VK_META &&
        keyStroke.getKeyCode () != KeyEvent.VK_ALT &&
        keyStroke.getKeyCode () != KeyEvent.VK_ALT_GRAPH) {
        sb.append (Utilities.keyToString (
            KeyStroke.getKeyStroke (keyStroke.getKeyCode (), 0)
        ));
    }
    return sb.toString ();
}
 
Example 8
Source File: InstantRefactoringPerformer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static String getKeyStrokeAsText(KeyStroke keyStroke) {
    int modifiers = keyStroke.getModifiers();
    StringBuilder sb = new StringBuilder();
    sb.append('\'');
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
        sb.append("Ctrl+"); //NOI18N
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
        sb.append("Alt+"); //NOI18N
    }
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
        sb.append("Shift+"); //NOI18N
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
        sb.append("Meta+"); //NOI18N
    }
    if (keyStroke.getKeyCode() != KeyEvent.VK_SHIFT
            && keyStroke.getKeyCode() != KeyEvent.VK_CONTROL
            && keyStroke.getKeyCode() != KeyEvent.VK_META
            && keyStroke.getKeyCode() != KeyEvent.VK_ALT
            && keyStroke.getKeyCode() != KeyEvent.VK_ALT_GRAPH) {
        sb.append(org.openide.util.Utilities.keyToString(
                KeyStroke.getKeyStroke(keyStroke.getKeyCode(), 0)
        ));
    }
    sb.append('\'');
    return sb.toString();
}
 
Example 9
Source File: SearchResultRender.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static String getKeyStrokeAsText (KeyStroke keyStroke) {
    if (keyStroke == null)
        return "";
    int modifiers = keyStroke.getModifiers ();
    StringBuffer sb = new StringBuffer ();
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0)
        sb.append ("Ctrl+");
    if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0)
        sb.append ("Alt+");
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0)
        sb.append ("Shift+");
    if ((modifiers & InputEvent.META_DOWN_MASK) > 0)
        if (Utilities.isMac()) {
            // Mac cloverleaf symbol
            sb.append ("\u2318+");
        } else if (isSolaris()) {
            // Sun meta symbol
            sb.append ("\u25C6+");
        } else {
            sb.append ("Meta+");
        }
    if (keyStroke.getKeyCode () != KeyEvent.VK_SHIFT &&
        keyStroke.getKeyCode () != KeyEvent.VK_CONTROL &&
        keyStroke.getKeyCode () != KeyEvent.VK_META &&
        keyStroke.getKeyCode () != KeyEvent.VK_ALT &&
        keyStroke.getKeyCode () != KeyEvent.VK_ALT_GRAPH
    )
        sb.append (Utilities.keyToString (
            KeyStroke.getKeyStroke (keyStroke.getKeyCode (), 0)
        ));
    return sb.toString ();
}
 
Example 10
Source File: SelfSamplerAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void eventDispatched(AWTEvent event) {
    KeyEvent kevent = (KeyEvent) event;
    if (kevent.getID() == KeyEvent.KEY_RELEASED && kevent.getKeyCode() == KeyEvent.VK_ALT_GRAPH) { // AltGr
        actionPerformed(new ActionEvent(this, event.getID(), "shortcut")); //NOI18N
        kevent.consume();
    }
}
 
Example 11
Source File: PopupManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override void keyPressed(KeyEvent e){
    if (e != null && popup != null && popup.isShowing()) {
        
        // get popup's registered keyboard actions
        ActionMap am = popup.getActionMap();
        InputMap  im = popup.getInputMap();
        
        // check whether popup registers keystroke
        KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e);
        Object obj = im.get(ks);
        LOG.log(Level.FINE, "Keystroke for event {0}: {1}; action-map-key={2}", new Object [] { e, ks, obj }); //NOI18N
        if (shouldPopupReceiveForwardedKeyboardAction(obj)) {
            // if yes, gets the popup's action for this keystroke, perform it 
            // and consume key event
            Action action = am.get(obj);
            LOG.log(Level.FINE, "Popup component''s action: {0}, {1}", new Object [] { action, action != null ? action.getValue(Action.NAME) : null }); //NOI18N

            /* Make sure to use the popup as the source of the action, since the popup is
            also providing the event. Not doing this, and instead invoking actionPerformed
            with a null ActionEvent, was one part of the problem seen in NETBEANS-403. */
            if (SwingUtilities.notifyAction(action, ks, e, popup, e.getModifiers())) {
              e.consume();
              return;
            }
        }

        if (e.getKeyCode() != KeyEvent.VK_CONTROL &&
            e.getKeyCode() != KeyEvent.VK_SHIFT &&
            e.getKeyCode() != KeyEvent.VK_ALT &&
            e.getKeyCode() != KeyEvent.VK_ALT_GRAPH &&
            e.getKeyCode() != KeyEvent.VK_META
        ) {
            // hide tooltip if any was shown
            Utilities.getEditorUI(textComponent).getToolTipSupport().setToolTipVisible(false);
        }
    }
}
 
Example 12
Source File: ShortcutOptionsPanel.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Action triggered when keyboard is used.
 * 
 * @param e Event.
 * @return True if processing should end.
 * @see java.awt.KeyEventDispatcher#dispatchKeyEvent(java.awt.event.KeyEvent)
 */
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
  int key = e.getKeyCode();
  if ((key == KeyEvent.VK_ALT) ||
      (key == KeyEvent.VK_ALT_GRAPH) ||
      (key == KeyEvent.VK_BACK_SPACE) ||
      (key == KeyEvent.VK_BEGIN) ||
      (key == KeyEvent.VK_CANCEL) ||
      (key == KeyEvent.VK_CAPS_LOCK) ||
      (key == KeyEvent.VK_CONTROL) ||
      (key == KeyEvent.VK_DELETE) ||
      (key == KeyEvent.VK_DOWN) ||
      (key == KeyEvent.VK_END) ||
      (key == KeyEvent.VK_ENTER) ||
      (key == KeyEvent.VK_LEFT) ||
      (key == KeyEvent.VK_PAGE_DOWN) ||
      (key == KeyEvent.VK_PAGE_UP) ||
      (key == KeyEvent.VK_RIGHT) ||
      (key == KeyEvent.VK_SHIFT) ||
      (key == KeyEvent.VK_TAB) ||
      (key == KeyEvent.VK_UP) ||
      (key == KeyEvent.VK_SHIFT)) {
    return false;
  }
  if (key != KeyEvent.VK_ESCAPE) {
    setKeyCode(key);
  }
  showNotice(false);
  KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this);
  return false;
}
 
Example 13
Source File: ModifierTracker.java    From pumpernickel with MIT License 5 votes vote down vote up
private void key(int code, boolean pressed) {
	if (code == KeyEvent.VK_ALT) {
		if (alt != pressed) {
			alt = pressed;
			fireAltChangeListeners();
		}
	} else if (code == KeyEvent.VK_ALT_GRAPH) {
		if (altGraph != pressed) {
			altGraph = pressed;
			fireAltGraphChangeListeners();
		}
	} else if (code == KeyEvent.VK_CONTROL) {
		if (ctrl != pressed) {
			ctrl = pressed;
			fireControlChangeListeners();
		}
	} else if (code == KeyEvent.VK_META) {
		if (meta != pressed) {
			meta = pressed;
			fireMetaChangeListeners();
		}
	} else if (code == KeyEvent.VK_SHIFT) {
		if (shift != pressed) {
			shift = pressed;
			fireShiftChangeListeners();
		}
	}
}
 
Example 14
Source File: ModifierTracker.java    From pumpernickel with MIT License 5 votes vote down vote up
public void eventDispatched(AWTEvent e) {
	if (e instanceof KeyEvent) {
		KeyEvent k = (KeyEvent) e;
		boolean pressed = k.getID() == KeyEvent.KEY_PRESSED;
		int code = k.getKeyCode();
		switch (code) {
		case KeyEvent.VK_ALT:
			if (alt != pressed) {
				alt = pressed;
				fireAltChangeListeners();
			}
			break;
		case KeyEvent.VK_ALT_GRAPH:
			if (altGraph != pressed) {
				altGraph = pressed;
				fireAltGraphChangeListeners();
			}
			break;
		case KeyEvent.VK_META:
			if (meta != pressed) {
				meta = pressed;
				fireMetaChangeListeners();
			}
			break;
		case KeyEvent.VK_SHIFT:
			if (shift != pressed) {
				shift = pressed;
				fireShiftChangeListeners();
			}
			break;
		case KeyEvent.VK_CONTROL:
			if (ctrl != pressed) {
				ctrl = pressed;
				fireControlChangeListeners();
			}
			break;
		}
	}
}
 
Example 15
Source File: DefaultKeyboardHandler.java    From tn5250j with GNU General Public License v2.0 4 votes vote down vote up
private void processVTKeyPressed(KeyEvent e) {


    keyProcessed = true;
    int keyCode = e.getKeyCode();

    if (isLinux && keyCode == KeyEvent.VK_ALT_GRAPH) {

      isAltGr = true;
    }

    if (keyCode == KeyEvent.VK_CAPS_LOCK ||
        keyCode == KeyEvent.VK_SHIFT ||
        keyCode == KeyEvent.VK_ALT ||
        keyCode == KeyEvent.VK_ALT_GRAPH
        ) {

      return;
    }

    KeyStroke ks = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers(), false);

    if (emulatorAction(ks, e)) {

      return;
    }

    if (isLinux)
      lastKeyStroke = KeyMapper.getKeyStrokeText(e, isAltGr);
    else
      lastKeyStroke = KeyMapper.getKeyStrokeText(e);

    if (lastKeyStroke != null && !lastKeyStroke.equals("null")) {

      if (lastKeyStroke.startsWith("[") || lastKeyStroke.length() == 1) {

        screen.sendKeys(lastKeyStroke);
        if (recording)
          recordBuffer.append(lastKeyStroke);
      } else {
        session.getGUI().executeMacro(lastKeyStroke);
      }
      if (lastKeyStroke.startsWith("[mark")) {
        if (lastKeyStroke.equals("[markleft]") ||
            lastKeyStroke.equals("[markright]") ||
            lastKeyStroke.equals("[markup]") ||
            lastKeyStroke.equals("[markdown]")) {
          session.getGUI().doKeyBoundArea(e, lastKeyStroke);
        }
      }
    } else
      keyProcessed = false;

    if (keyProcessed)
      e.consume();

  }
 
Example 16
Source File: StaffApplication.java    From RemoteSupportTool with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("Duplicates")
protected synchronized void doHandleKeyPress(KeyEvent e) {
    if (handler == null) return;
    //LOGGER.debug("key pressed: " + e.paramString());

    // Get code of the pressed key.
    // Keypad arrows are translated to regular arrow keys.
    final int keyCode;
    switch (e.getKeyCode()) {
        case KeyEvent.VK_KP_DOWN:
            keyCode = KeyEvent.VK_DOWN;
            break;
        case KeyEvent.VK_KP_LEFT:
            keyCode = KeyEvent.VK_LEFT;
            break;
        case KeyEvent.VK_KP_RIGHT:
            keyCode = KeyEvent.VK_RIGHT;
            break;
        case KeyEvent.VK_KP_UP:
            keyCode = KeyEvent.VK_UP;
            break;
        default:
            keyCode = e.getKeyCode();
            break;
    }

    // Never press undefined key codes.
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return;
    }

    // Never send caps lock, num lock and scroll lock key.
    if (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK || keyCode == KeyEvent.VK_SCROLL_LOCK) {
        return;
    }

    // Detect, if a control key was pressed.
    final boolean isControlKey = e.isActionKey() ||
            keyCode == KeyEvent.VK_BACK_SPACE ||
            keyCode == KeyEvent.VK_DELETE ||
            keyCode == KeyEvent.VK_ENTER ||
            keyCode == KeyEvent.VK_SPACE ||
            keyCode == KeyEvent.VK_TAB ||
            keyCode == KeyEvent.VK_ESCAPE ||
            keyCode == KeyEvent.VK_ALT ||
            keyCode == KeyEvent.VK_ALT_GRAPH ||
            keyCode == KeyEvent.VK_CONTROL ||
            keyCode == KeyEvent.VK_SHIFT ||
            keyCode == KeyEvent.VK_META;

    // Press control keys.
    if (isControlKey) {
        //LOGGER.debug("press key \"{}\" ({})", keyCode, KeyEvent.getKeyText(keyCode));
        handler.sendKeyPress(keyCode);
        e.consume();
    }

    // Press other keys, if they are pressed together with a modifier key.
    else if (e.isControlDown() || e.isMetaDown() || windowsKeyDown || (!SystemUtils.IS_OS_MAC && e.isAltDown())) {
        //LOGGER.debug("press key \"{}\" ({})", keyCode, KeyEvent.getKeyText(keyCode));
        handler.sendKeyPress(keyCode);
        if (!pressedKeys.contains(keyCode))
            pressedKeys.add(keyCode);
        e.consume();
    }

    // Remember, that the Windows key was pressed.
    if (keyCode == KeyEvent.VK_WINDOWS) {
        synchronized (Frame.this) {
            windowsKeyDown = true;
        }
    }
}
 
Example 17
Source File: VncClientPacketSender.java    From cosmic with Apache License 2.0 4 votes vote down vote up
private int mapAwtKeyToVncKey(final int key) {
    switch (key) {
        case KeyEvent.VK_BACK_SPACE:
            return 0xff08;
        case KeyEvent.VK_TAB:
            return 0xff09;
        case KeyEvent.VK_ENTER:
            return 0xff0d;
        case KeyEvent.VK_ESCAPE:
            return 0xff1b;
        case KeyEvent.VK_INSERT:
            return 0xff63;
        case KeyEvent.VK_DELETE:
            return 0xffff;
        case KeyEvent.VK_HOME:
            return 0xff50;
        case KeyEvent.VK_END:
            return 0xff57;
        case KeyEvent.VK_PAGE_UP:
            return 0xff55;
        case KeyEvent.VK_PAGE_DOWN:
            return 0xff56;
        case KeyEvent.VK_LEFT:
            return 0xff51;
        case KeyEvent.VK_UP:
            return 0xff52;
        case KeyEvent.VK_RIGHT:
            return 0xff53;
        case KeyEvent.VK_DOWN:
            return 0xff54;
        case KeyEvent.VK_F1:
            return 0xffbe;
        case KeyEvent.VK_F2:
            return 0xffbf;
        case KeyEvent.VK_F3:
            return 0xffc0;
        case KeyEvent.VK_F4:
            return 0xffc1;
        case KeyEvent.VK_F5:
            return 0xffc2;
        case KeyEvent.VK_F6:
            return 0xffc3;
        case KeyEvent.VK_F7:
            return 0xffc4;
        case KeyEvent.VK_F8:
            return 0xffc5;
        case KeyEvent.VK_F9:
            return 0xffc6;
        case KeyEvent.VK_F10:
            return 0xffc7;
        case KeyEvent.VK_F11:
            return 0xffc8;
        case KeyEvent.VK_F12:
            return 0xffc9;
        case KeyEvent.VK_SHIFT:
            return 0xffe1;
        case KeyEvent.VK_CONTROL:
            return 0xffe3;
        case KeyEvent.VK_META:
            return 0xffe7;
        case KeyEvent.VK_ALT:
            return 0xffe9;
        case KeyEvent.VK_ALT_GRAPH:
            return 0xffea;
        case KeyEvent.VK_BACK_QUOTE:
            return 0x0060;
    }

    return key;
}
 
Example 18
Source File: VncClientPacketSender.java    From cloudstack with Apache License 2.0 4 votes vote down vote up
private int mapAwtKeyToVncKey(int key) {
    switch (key) {
        case KeyEvent.VK_BACK_SPACE:
            return 0xff08;
        case KeyEvent.VK_TAB:
            return 0xff09;
        case KeyEvent.VK_ENTER:
            return 0xff0d;
        case KeyEvent.VK_ESCAPE:
            return 0xff1b;
        case KeyEvent.VK_INSERT:
            return 0xff63;
        case KeyEvent.VK_DELETE:
            return 0xffff;
        case KeyEvent.VK_HOME:
            return 0xff50;
        case KeyEvent.VK_END:
            return 0xff57;
        case KeyEvent.VK_PAGE_UP:
            return 0xff55;
        case KeyEvent.VK_PAGE_DOWN:
            return 0xff56;
        case KeyEvent.VK_LEFT:
            return 0xff51;
        case KeyEvent.VK_UP:
            return 0xff52;
        case KeyEvent.VK_RIGHT:
            return 0xff53;
        case KeyEvent.VK_DOWN:
            return 0xff54;
        case KeyEvent.VK_F1:
            return 0xffbe;
        case KeyEvent.VK_F2:
            return 0xffbf;
        case KeyEvent.VK_F3:
            return 0xffc0;
        case KeyEvent.VK_F4:
            return 0xffc1;
        case KeyEvent.VK_F5:
            return 0xffc2;
        case KeyEvent.VK_F6:
            return 0xffc3;
        case KeyEvent.VK_F7:
            return 0xffc4;
        case KeyEvent.VK_F8:
            return 0xffc5;
        case KeyEvent.VK_F9:
            return 0xffc6;
        case KeyEvent.VK_F10:
            return 0xffc7;
        case KeyEvent.VK_F11:
            return 0xffc8;
        case KeyEvent.VK_F12:
            return 0xffc9;
        case KeyEvent.VK_SHIFT:
            return 0xffe1;
        case KeyEvent.VK_CONTROL:
            return 0xffe3;
        case KeyEvent.VK_META:
            return 0xffe7;
        case KeyEvent.VK_ALT:
            return 0xffe9;
        case KeyEvent.VK_ALT_GRAPH:
            return 0xffea;
        case KeyEvent.VK_BACK_QUOTE:
            return 0x0060;
    }

    return key;
}
 
Example 19
Source File: NbKeymap.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Action getAction(final KeyStroke key) {
    switch (key.getKeyCode()) {
    case KeyEvent.VK_SHIFT:
    case KeyEvent.VK_CONTROL:
    case KeyEvent.VK_ALT:
    case KeyEvent.VK_ALT_GRAPH:
    case KeyEvent.VK_META:
    case KeyEvent.VK_UNDEFINED:
    case KeyEvent.CHAR_UNDEFINED:
            // Not actually a bindable key press.
            return null;
    }
    if (key.isOnKeyRelease()) {
        // Again, not really our business here.
        return null;
    }
    LOG.log(Level.FINE, "getAction {0}", key);
    Map<KeyStroke,Binding> binder = bindings();
    for (KeyStroke ctx : context) {
        Binding sub = binder.get(ctx);
        if (sub == null) {
            resetContext();
            return BROKEN; // no entry found after known prefix
        }
        binder = sub.nested;
        if (binder == null) {
            resetContext();
            return BROKEN; // anomalous, expected to find submap here
        }
    }
    Binding b = binder.get(key);
    if (b == null) {
        resetContext();
        return null; // normal, not found
    }
    if (b.nested == null) {
        resetContext();
        return b.loadAction(); // found real action
    } else {
        return new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                shiftContext(key); // entering submap
            }
        };
    }
}
 
Example 20
Source File: DefaultKeyboardHandler.java    From tn5250j with GNU General Public License v2.0 3 votes vote down vote up
private void processVTKeyReleased(KeyEvent e) {


    if (isLinux && e.getKeyCode() == KeyEvent.VK_ALT_GRAPH) {

      isAltGr = false;
    }

    if (Character.isISOControl(e.getKeyChar()) || keyProcessed || e.isConsumed())
      return;

    String s = KeyMapper.getKeyStrokeText(e);

    if (s != null) {

      if (s.startsWith("[")) {
        screen.sendKeys(s);
        if (recording)
          recordBuffer.append(s);
      } else
        session.getGUI().executeMacro(s);

    } else
      keyProcessed = false;

    if (keyProcessed)
      e.consume();
  }