Example usage for java.awt.event KeyEvent VK_ESCAPE

List of usage examples for java.awt.event KeyEvent VK_ESCAPE

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_ESCAPE.

Prototype

int VK_ESCAPE

To view the source code for java.awt.event KeyEvent VK_ESCAPE.

Click Source Link

Document

Constant for the ESCAPE virtual key.

Usage

From source file:org.languagetool.gui.Main.java

private void tagTextAndDisplayResults() {
    JLanguageTool langTool = ltSupport.getLanguageTool();
    // tag text//  w w w . j a  v  a 2  s  . c  om
    List<String> sentences = langTool.sentenceTokenize(textArea.getText());
    StringBuilder sb = new StringBuilder();
    if (taggerShowsDisambigLog) {
        sb.append("<table>");
        sb.append("<tr>");
        sb.append("<td><b>");
        sb.append(messages.getString("token"));
        sb.append("</b></td>");
        sb.append("<td><b>");
        sb.append(messages.getString("disambiguatorLog"));
        sb.append("</b></td>");
        sb.append("</tr>");
        boolean odd = true;
        try {
            for (String sent : sentences) {
                AnalyzedSentence analyzed = langTool.getAnalyzedSentence(sent);
                odd = appendTagsWithDisambigLog(sb, analyzed, odd);
            }
        } catch (Exception e) {
            sb.append(getStackTraceAsHtml(e));
        }
        sb.append("</table>");
    } else {
        try {
            for (String sent : sentences) {
                AnalyzedSentence analyzed = langTool.getAnalyzedSentence(sent);
                String analyzedString = StringTools.escapeHTML(analyzed.toString(","))
                        .replace("&lt;S&gt;", "&lt;S&gt;<br>").replace("[", "<font color='" + TAG_COLOR + "'>[")
                        .replace("]", "]</font><br>");
                sb.append(analyzedString).append('\n');
            }
        } catch (Exception e) {
            sb.append(getStackTraceAsHtml(e));
        }
    }
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (taggerDialog == null) {
                taggerDialog = new JDialog(frame);
                taggerDialog.setTitle(messages.getString("taggerWindowTitle"));
                taggerDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
                taggerDialog.setResizable(true);
                taggerDialog.setSize(640, 480);
                taggerDialog.setLocationRelativeTo(frame);
                KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
                ActionListener actionListener = actionEvent -> taggerDialog.setVisible(false);
                taggerDialog.getRootPane().registerKeyboardAction(actionListener, stroke,
                        JComponent.WHEN_IN_FOCUSED_WINDOW);
                JPanel panel = new JPanel(new GridBagLayout());
                taggerDialog.add(panel);
                taggerArea = new JTextPane();
                taggerArea.setContentType("text/html");
                taggerArea.setEditable(false);
                GridBagConstraints c = new GridBagConstraints();
                c.gridx = 0;
                c.gridwidth = 2;
                c.gridy = 0;
                c.weightx = 1.0;
                c.weighty = 1.0;
                c.insets = new Insets(8, 8, 4, 8);
                c.fill = GridBagConstraints.BOTH;
                panel.add(new JScrollPane(taggerArea), c);
                c.gridwidth = 1;
                c.gridx = 0;
                c.gridy = 1;
                c.weightx = 0.0;
                c.weighty = 0.0;
                c.insets = new Insets(4, 8, 8, 8);
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.EAST;
                JCheckBox showDisAmbig = new JCheckBox(messages.getString("ShowDisambiguatorLog"));
                showDisAmbig.setSelected(taggerShowsDisambigLog);
                showDisAmbig.addItemListener((ItemEvent e) -> {
                    taggerShowsDisambigLog = e.getStateChange() == ItemEvent.SELECTED;
                    ltSupport.getConfig().setTaggerShowsDisambigLog(taggerShowsDisambigLog);
                });
                panel.add(showDisAmbig, c);
                c.gridx = 1;
                JButton closeButton = new JButton(messages.getString("guiCloseButton"));
                closeButton.addActionListener(actionListener);
                panel.add(closeButton, c);
            }
            // orientation each time should be set as language may is changed
            taggerDialog.applyComponentOrientation(
                    ComponentOrientation.getOrientation(languageBox.getSelectedLanguage().getLocale()));

            taggerDialog.setVisible(true);
            taggerArea.setText(HTML_FONT_START + sb + HTML_FONT_END);
        }
    });
}

From source file:com.sshtools.sshterm.emulation.TerminalEmulation.java

public void keyPressed(int keyCode, char keyChar, int modifiers) {
    if (debug > 0) {
        System.out.println("keyPressed(" + keyCode + "," + keyChar + "," + modifiers);
    }// w  ww  . j av  a  2 s  .  co  m
    boolean control = (modifiers & VDUInput.KEY_CONTROL) != 0;
    boolean shift = (modifiers & VDUInput.KEY_SHIFT) != 0;
    boolean alt = (modifiers & VDUInput.KEY_ALT) != 0;
    int xind;
    String[] fmap;
    xind = 0;
    fmap = FunctionKey;
    if (shift) {
        fmap = FunctionKeyShift;
        xind = 1;
    }
    if (control) {
        fmap = FunctionKeyCtrl;
        xind = 2;
    }
    if (alt) {
        fmap = FunctionKeyAlt;
        xind = 3;
    }
    switch (keyCode) {
    case KeyEvent.VK_PAUSE:
        if (shift || control) {
            sendTelnetCommand((byte) 243);
        }

        // BREAK
        break;
    case KeyEvent.VK_ESCAPE:
        writeSpecial(Escape[xind]);
        break;
    case KeyEvent.VK_F1:
        writeSpecial(fmap[1]);
        break;
    case KeyEvent.VK_F2:
        writeSpecial(fmap[2]);
        break;
    case KeyEvent.VK_F3:
        writeSpecial(fmap[3]);
        break;
    case KeyEvent.VK_F4:
        writeSpecial(fmap[4]);
        break;
    case KeyEvent.VK_F5:
        writeSpecial(fmap[5]);
        break;
    case KeyEvent.VK_F6:
        writeSpecial(fmap[6]);
        break;
    case KeyEvent.VK_F7:
        writeSpecial(fmap[7]);
        break;
    case KeyEvent.VK_F8:
        writeSpecial(fmap[8]);
        break;
    case KeyEvent.VK_F9:
        writeSpecial(fmap[9]);
        break;
    case KeyEvent.VK_F10:
        writeSpecial(fmap[10]);
        break;
    case KeyEvent.VK_F11:
        writeSpecial(fmap[11]);
        break;
    case KeyEvent.VK_F12:
        writeSpecial(fmap[12]);
        break;
    case KeyEvent.VK_UP:
        writeSpecial(KeyUp[xind]);
        break;
    case KeyEvent.VK_DOWN:
        writeSpecial(KeyDown[xind]);
        break;
    case KeyEvent.VK_LEFT:
        writeSpecial(KeyLeft[xind]);
        break;
    case KeyEvent.VK_RIGHT:
        writeSpecial(KeyRight[xind]);
        break;
    case KeyEvent.VK_PAGE_DOWN:
        writeSpecial(NextScn[xind]);
        break;
    case KeyEvent.VK_PAGE_UP:
        writeSpecial(PrevScn[xind]);
        break;
    case KeyEvent.VK_INSERT:
        writeSpecial(Insert[xind]);
        break;
    case KeyEvent.VK_DELETE:
        writeSpecial(Remove[xind]);
        break;
    case KeyEvent.VK_BACK_SPACE:
        writeSpecial(BackSpace[xind]);
        if (localecho) {
            if (BackSpace[xind] == "\b" || BackSpace[xind] == "\u007f") {
                putString("\b \b");
                // make the last char 'deleted'
            } else {
                putString(BackSpace[xind]);
                // echo it
            }
        }
        break;
    case KeyEvent.VK_HOME:
        writeSpecial(KeyHome[xind]);
        break;
    case KeyEvent.VK_END:
        writeSpecial(KeyEnd[xind]);
        break;
    case KeyEvent.VK_NUM_LOCK:
        if (vms && control) {
            writeSpecial(PF1);
        }
        if (!control) {
            numlock = !numlock;
        }
        break;
    case KeyEvent.VK_CAPS_LOCK:
        capslock = !capslock;
        return;
    case KeyEvent.VK_SHIFT:
    case KeyEvent.VK_CONTROL:
    case KeyEvent.VK_ALT:
        return;
    default:
        break;
    }
}

From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java

public JPanel createDetailsView() {
    final VFSJFileChooser chooser = getFileChooser();

    JPanel p = new JPanel(new BorderLayout());

    final JTable detailsTable = new JTable(getDetailsTableModel()) {
        // Handle Escape key events here
        @Override/* w w  w. java 2s . c  o  m*/
        protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
            if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) && (getCellEditor() == null)) {
                // We are not editing, forward to filechooser.
                chooser.dispatchEvent(e);

                return true;
            }

            return super.processKeyBinding(ks, e, condition, pressed);
        }

        @Override
        public void tableChanged(TableModelEvent e) {
            super.tableChanged(e);

            if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
                // update header with possibly changed column set
                updateDetailsColumnModel(this);
            }
        }
    };

    //        detailsTable.setRowSorter(getRowSorter());
    detailsTable.setAutoCreateColumnsFromModel(false);
    detailsTable.setComponentOrientation(chooser.getComponentOrientation());
    //detailsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    detailsTable.setShowGrid(false);
    detailsTable.putClientProperty("JTable.autoStartsEdit", Boolean.FALSE);

    //        detailsTable.addKeyListener(detailsKeyListener);
    Font font = list.getFont();
    detailsTable.setFont(font);
    detailsTable.setIntercellSpacing(new Dimension(0, 0));

    TableCellRenderer headerRenderer = new AlignableTableHeaderRenderer(
            detailsTable.getTableHeader().getDefaultRenderer());
    detailsTable.getTableHeader().setDefaultRenderer(headerRenderer);

    TableCellRenderer cellRenderer = new DetailsTableCellRenderer(chooser);
    detailsTable.setDefaultRenderer(Object.class, cellRenderer);

    // So that drag can be started on a mouse press
    detailsTable.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    detailsTable.addMouseListener(getMouseHandler());
    // No need to addListSelectionListener because selections are forwarded
    // to our JList.

    // 4835633 : tell BasicTableUI that this is a file list
    detailsTable.putClientProperty("Table.isFileList", Boolean.TRUE);

    if (listViewWindowsStyle) {
        detailsTable.addFocusListener(repaintListener);
    }

    JTableHeader header = detailsTable.getTableHeader();
    header.setUpdateTableInRealTime(true);
    header.addMouseListener(detailsTableModel.new ColumnListener());
    header.setReorderingAllowed(true);

    // TAB/SHIFT-TAB should transfer focus and ENTER should select an item.
    // We don't want them to navigate within the table
    ActionMap am = SwingUtilities.getUIActionMap(detailsTable);
    am.remove("selectNextRowCell");
    am.remove("selectPreviousRowCell");
    am.remove("selectNextColumnCell");
    am.remove("selectPreviousColumnCell");
    detailsTable.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
    detailsTable.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);

    JScrollPane scrollpane = new JScrollPane(detailsTable);
    scrollpane.setComponentOrientation(chooser.getComponentOrientation());
    LookAndFeel.installColors(scrollpane.getViewport(), "Table.background", "Table.foreground");

    // Adjust width of first column so the table fills the viewport when
    // first displayed (temporary listener).
    scrollpane.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            JScrollPane sp = (JScrollPane) e.getComponent();
            fixNameColumnWidth(sp.getViewport().getSize().width);
            sp.removeComponentListener(this);
        }
    });

    // 4835633.
    // If the mouse is pressed in the area below the Details view table, the
    // event is not dispatched to the Table MouseListener but to the
    // scrollpane.  Listen for that here so we can clear the selection.
    scrollpane.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            JScrollPane jsp = ((JScrollPane) e.getComponent());
            JTable table = (JTable) jsp.getViewport().getView();

            if (!e.isShiftDown()
                    || (table.getSelectionModel().getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)) {
                clearSelection();

                TableCellEditor tce = table.getCellEditor();

                if (tce != null) {
                    tce.stopCellEditing();
                }
            }
        }
    });

    detailsTable.setForeground(list.getForeground());
    detailsTable.setBackground(list.getBackground());

    if (listViewBorder != null) {
        scrollpane.setBorder(listViewBorder);
    }

    p.add(scrollpane, BorderLayout.CENTER);

    detailsTableModel.fireTableStructureChanged();

    return p;
}

From source file:ru.goodfil.catalog.ui.forms.FiltersPanel.java

private void tbSeriaKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        btnSearchMotorsActionPerformed(null);
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        tbSeria.setText("");
    }/*from   w  w w .  j  a v  a  2s .c o  m*/
}

From source file:ru.goodfil.catalog.ui.forms.FiltersPanel.java

private void tbModelKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        btnSearchMotorsActionPerformed(null);
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        tbModel.setText("");
    }//from w ww .jav  a  2 s.  co  m
}

From source file:ru.goodfil.catalog.ui.forms.FiltersPanel.java

private void tbEngineKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        btnSearchMotorsActionPerformed(null);
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        tbEngine.setText("");
    }//www. j  a v  a 2s .  c o  m
}

From source file:ru.goodfil.catalog.ui.forms.FiltersPanel.java

private void tbDateFKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        btnSearchMotorsActionPerformed(null);
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        tbDateF.setText("");
    }/*from w w w  .  j  ava 2s.  com*/
}

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

/**
 * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum
 * @param keycode int, a java keycode/*from ww w .  j  a  va  2  s. c  o  m*/
 * @return Keys enum for (primarily) non-printable (control) characters, or null.
 */
public static Keys convertToKeys(int keycode) {
    Keys key = null;
    switch (keycode) {
    case java.awt.event.KeyEvent.VK_ADD:
        key = Keys.ADD;
        break;
    case java.awt.event.KeyEvent.VK_ALT:
        key = Keys.ALT;
        break;
    case java.awt.event.KeyEvent.VK_KP_DOWN:
        key = Keys.ARROW_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_KP_LEFT:
        key = Keys.ARROW_LEFT;
        break;
    case java.awt.event.KeyEvent.VK_KP_RIGHT:
        key = Keys.ARROW_RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_KP_UP:
        key = Keys.ARROW_UP;
        break;
    case java.awt.event.KeyEvent.VK_BACK_SPACE:
        key = Keys.BACK_SPACE;
        break;
    case java.awt.event.KeyEvent.VK_CANCEL:
        key = Keys.CANCEL;
        break;
    case java.awt.event.KeyEvent.VK_CLEAR:
        key = Keys.CLEAR;
        break;
    case java.awt.event.KeyEvent.VK_WINDOWS:
        key = Keys.COMMAND;
        break;
    case java.awt.event.KeyEvent.VK_CONTROL:
        key = Keys.CONTROL;
        break;
    case java.awt.event.KeyEvent.VK_DECIMAL:
        key = Keys.DECIMAL;
        break;
    case java.awt.event.KeyEvent.VK_DELETE:
        key = Keys.DELETE;
        break;
    case java.awt.event.KeyEvent.VK_DIVIDE:
        key = Keys.DIVIDE;
        break;
    case java.awt.event.KeyEvent.VK_DOWN:
        key = Keys.DOWN;
        break;
    case java.awt.event.KeyEvent.VK_END:
        key = Keys.END;
        break;
    case java.awt.event.KeyEvent.VK_ENTER:
        key = Keys.ENTER;
        break;
    case java.awt.event.KeyEvent.VK_EQUALS:
        key = Keys.EQUALS;
        break;
    case java.awt.event.KeyEvent.VK_ESCAPE:
        key = Keys.ESCAPE;
        break;
    case java.awt.event.KeyEvent.VK_F1:
        key = Keys.F1;
        break;
    case java.awt.event.KeyEvent.VK_F2:
        key = Keys.F2;
        break;
    case java.awt.event.KeyEvent.VK_F3:
        key = Keys.F3;
        break;
    case java.awt.event.KeyEvent.VK_F4:
        key = Keys.F4;
        break;
    case java.awt.event.KeyEvent.VK_F5:
        key = Keys.F5;
        break;
    case java.awt.event.KeyEvent.VK_F6:
        key = Keys.F6;
        break;
    case java.awt.event.KeyEvent.VK_F7:
        key = Keys.F7;
        break;
    case java.awt.event.KeyEvent.VK_F8:
        key = Keys.F8;
        break;
    case java.awt.event.KeyEvent.VK_F9:
        key = Keys.F9;
        break;
    case java.awt.event.KeyEvent.VK_F10:
        key = Keys.F10;
        break;
    case java.awt.event.KeyEvent.VK_F11:
        key = Keys.F11;
        break;
    case java.awt.event.KeyEvent.VK_F12:
        key = Keys.F12;
        break;
    case java.awt.event.KeyEvent.VK_HELP:
        key = Keys.HELP;
        break;
    case java.awt.event.KeyEvent.VK_HOME:
        key = Keys.HOME;
        break;
    case java.awt.event.KeyEvent.VK_INSERT:
        key = Keys.INSERT;
        break;
    case java.awt.event.KeyEvent.VK_LEFT:
        key = Keys.LEFT;
        break;
    case java.awt.event.KeyEvent.VK_META:
        key = Keys.META;
        break;
    case java.awt.event.KeyEvent.VK_MULTIPLY:
        key = Keys.MULTIPLY;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD0:
        key = Keys.NUMPAD0;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD1:
        key = Keys.NUMPAD1;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD2:
        key = Keys.NUMPAD2;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD3:
        key = Keys.NUMPAD3;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD4:
        key = Keys.NUMPAD4;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD5:
        key = Keys.NUMPAD5;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD6:
        key = Keys.NUMPAD6;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD7:
        key = Keys.NUMPAD7;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD8:
        key = Keys.NUMPAD8;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD9:
        key = Keys.NUMPAD9;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_DOWN:
        key = Keys.PAGE_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_UP:
        key = Keys.PAGE_UP;
        break;
    case java.awt.event.KeyEvent.VK_PAUSE:
        key = Keys.PAUSE;
        break;
    case java.awt.event.KeyEvent.VK_RIGHT:
        key = Keys.RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_SEMICOLON:
        key = Keys.SEMICOLON;
        break;
    case java.awt.event.KeyEvent.VK_SEPARATOR:
        key = Keys.SEPARATOR;
        break;
    case java.awt.event.KeyEvent.VK_SHIFT:
        key = Keys.SHIFT;
        break;
    case java.awt.event.KeyEvent.VK_SPACE:
        key = Keys.SPACE;
        break;
    case java.awt.event.KeyEvent.VK_SUBTRACT:
        key = Keys.SUBTRACT;
        break;
    case java.awt.event.KeyEvent.VK_TAB:
        key = Keys.TAB;
        break;
    case java.awt.event.KeyEvent.VK_UP:
        key = Keys.UP;
        break;
    }
    return key;
}

From source file:ru.goodfil.catalog.ui.forms.FiltersPanel.java

private void tbDateTKeyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        btnSearchMotorsActionPerformed(null);
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        tbDateT.setText("");
    }/*  w  w  w  .  ja va 2s.c o  m*/
}

From source file:com.sshtools.sshterm.emulation.TerminalEmulation.java

public void keyTyped(int keyCode, char keyChar, int modifiers) {
    if (debug > 0) {
        System.out.println("keyTyped(" + keyCode + "," + keyChar + "," + modifiers);
    }//from  www  . j a v  a2 s .c  om
    //  If there is a scrollbar, scroll to the end
    if ((display != null) && (display.getScrollBar() != null)) {
        if (display.getScrollBar().getValue() != display.getScrollBar().getMaximum()) {
            display.getScrollBar().setValue(display.getScrollBar().getMaximum());
        }
    }
    boolean control = (modifiers & VDUInput.KEY_CONTROL) != 0;
    boolean shift = (modifiers & VDUInput.KEY_SHIFT) != 0;
    // fix problem with Linux Java 6 -- really nasty
    if (control && keyChar >= 'a' && keyChar <= 'z')
        keyChar = (char) (keyChar - 96);
    if (control && shift && keyChar >= 'A' && keyChar <= 'Z')
        keyChar = (char) (keyChar - 64);
    boolean alt = (modifiers & VDUInput.KEY_ALT) != 0;
    if (keyChar == '\t') {
        if (shift) {
            write(TabKey[1], false);
        } else {
            if (control) {
                write(TabKey[2], false);
            } else {
                if (alt) {
                    write(TabKey[3], false);
                } else {
                    write(TabKey[0], false);
                }
            }
        }
        return;
    }
    if (alt) {
        //04/04/07 commented out to stop shortcuts causing strange characters.
        //write("" + ( (char) (keyChar | 0x80)));
        return;
    }
    if (((keyCode == KeyEvent.VK_ENTER) || (keyChar == 10)) && !control) {
        if (((eol == EOL_DEFAULT) && sendcrlf) || (eol == EOL_CR_LF)) {
            write("\r\n", false);
            if (localecho) {
                putString("\r\n");
            }
        } else {
            write("\r", false);
            if (localecho) {
                putString("\r");
            }
        }
        return;
    }
    if ((keyCode == 10) && !control) {
        System.out.println("Sending \\r");
        write("\r", false);
        return;
    }
    // FIXME: on german PC keyboards you have to use Alt-Ctrl-q to get an @,
    // so we can't just use it here... will probably break some other VMS
    // codes.  -Marcus
    // if(((!vms && keyChar == '2') || keyChar == '@' || keyChar == ' ')
    //    && control)
    if (((!vms && (keyChar == '2')) || (keyChar == ' ')) && control) {
        write("" + (char) 0);
    }
    if (vms) {
        if ((keyChar == 127) && !control) {
            if (shift) {
                writeSpecial(Insert[0]);
            }
            //  VMS shift delete = insert
            else {
                writeSpecial(Remove[0]);
            }
            //  VMS delete = remove
            return;
        } else if (control) {
            switch (keyChar) {
            case '0':
                writeSpecial(Numpad[0]);
                return;
            case '1':
                writeSpecial(Numpad[1]);
                return;
            case '2':
                writeSpecial(Numpad[2]);
                return;
            case '3':
                writeSpecial(Numpad[3]);
                return;
            case '4':
                writeSpecial(Numpad[4]);
                return;
            case '5':
                writeSpecial(Numpad[5]);
                return;
            case '6':
                writeSpecial(Numpad[6]);
                return;
            case '7':
                writeSpecial(Numpad[7]);
                return;
            case '8':
                writeSpecial(Numpad[8]);
                return;
            case '9':
                writeSpecial(Numpad[9]);
                return;
            case '.':
                writeSpecial(KPPeriod);
                return;
            case '-':
            case 31:
                writeSpecial(KPMinus);
                return;
            case '+':
                writeSpecial(KPComma);
                return;
            case 10:
                writeSpecial(KPEnter);
                return;
            case '/':
                writeSpecial(PF2);
                return;
            case '*':
                writeSpecial(PF3);
                return;
            /*
             *  NUMLOCK handled in keyPressed
            */
            default:
                break;
            }
        }
        /*
         *  Now what does this do and how did it get here. -Marcus
         *  if (shift && keyChar < 32) {
         *  write(PF1+(char)(keyChar + 64));
         *  return;
         *  }
         */
    }
    if (debug > 2) {
        System.out.println("vt320: keyPressed " + keyCode + "\"" + keyChar + "\"");
    }
    // FIXME: not used?
    String[] fmap;
    int xind;
    xind = 0;
    fmap = FunctionKey;
    if (shift) {
        fmap = FunctionKeyShift;
        xind = 1;
    }
    if (control) {
        fmap = FunctionKeyCtrl;
        xind = 2;
    }
    if (alt) {
        fmap = FunctionKeyAlt;
        xind = 3;
    }
    if (keyCode == KeyEvent.VK_ESCAPE) {
        writeSpecial(Escape[xind]);
        return;
    }
    if ((modifiers & VDUInput.KEY_ACTION) != 0) {
        switch (keyCode) {
        case KeyEvent.VK_NUMPAD0:
            writeSpecial(Numpad[0]);
            return;
        case KeyEvent.VK_NUMPAD1:
            writeSpecial(Numpad[1]);
            return;
        case KeyEvent.VK_NUMPAD2:
            writeSpecial(Numpad[2]);
            return;
        case KeyEvent.VK_NUMPAD3:
            writeSpecial(Numpad[3]);
            return;
        case KeyEvent.VK_NUMPAD4:
            writeSpecial(Numpad[4]);
            return;
        case KeyEvent.VK_NUMPAD5:
            writeSpecial(Numpad[5]);
            return;
        case KeyEvent.VK_NUMPAD6:
            writeSpecial(Numpad[6]);
            return;
        case KeyEvent.VK_NUMPAD7:
            writeSpecial(Numpad[7]);
            return;
        case KeyEvent.VK_NUMPAD8:
            writeSpecial(Numpad[8]);
            return;
        case KeyEvent.VK_NUMPAD9:
            writeSpecial(Numpad[9]);
            return;
        case KeyEvent.VK_DECIMAL:
            writeSpecial(NUMDot[xind]);
            return;
        case KeyEvent.VK_ADD:
            writeSpecial(NUMPlus[xind]);
            return;
        }
    }
    if (!((keyChar == 8) || (keyChar == 127) || (keyChar == '\r') || (keyChar == '\n'))) {
        write("" + keyChar);
        return;
    }
}