void (KeyEvent e) { if (e.isConsumed() || !myEnabled) return; String old = myString; if (e.getID() == KeyEvent.KEY_PRESSED) { if (KeymapUtil.isEventForAction(e, "EditorDeleteToWordStart")) { if (isHoldingFilter()) { while (!myString.isEmpty() && !Character.isWhitespace(myString.charAt(myString.length() - 1))) { backspace(); } e.consume(); } } else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { backspace(); e.consume(); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { if (isHoldingFilter()) { updatePattern(""); e.consume(); } else if (myJustActivated) { // Special case: speed search was activated through the API without typing anything, should be cancelled on Esc. myJustActivated = false; update(); e.consume(); } } } else if (e.getID() == KeyEvent.KEY_TYPED) { if (!UIUtil.isReallyTypedEvent(e)) return; // key-char is good only on KEY_TYPED // for example: key-char on ctrl-J PRESSED is \n // see https://en.wikipedia.org/wiki/Control_character char ch = e.getKeyChar(); if (Character.isLetterOrDigit(ch) || !startedWithWhitespace(ch) && PUNCTUATION_MARKS.indexOf(ch) != -1) { type(Character.toString(ch)); e.consume(); } } if (!old.equalsIgnoreCase(myString)) { update(); } }