handle keydown event
197035
function dispatch(event, scope){
    var key, handler, k, i, modifiersMatch;
    key = event.keyCode;

    // if a modifier key, set the key.<modifierkeyname> property to true and return
    if(key == 93 || key == 224) key = 91; // right command on webkit, command on Gecko
    if(key in _mods) {
      _mods[key] = true;
      // 'assignKey' from inside this closure is exported to window.key
      for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = true;
      return;
    }

    // see if we need to ignore the keypress (ftiler() can can be overridden)
    // by default ignore key presses if a select, textarea, or input is focused
    if(!assignKey.filter.call(this, event)) return;

    // abort if no potentially matching shortcuts found
    if (!(key in _handlers)) return;

    // for each potential shortcut
    for (i = 0; i < _handlers[key].length; i++) {
      handler = _handlers[key][i];

      // see if it's in the current scope
      if(handler.scope == scope || handler.scope == 'all'){
        // check if modifiers match if any
        modifiersMatch = handler.mods.length > 0;
        for(k in _mods)
          if((!_mods[k] && index(handler.mods, +k) > -1) ||
            (_mods[k] && index(handler.mods, +k) == -1)) modifiersMatch = false;
        // call the handler and stop the event if neccessary
        if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){
          if(handler.method(event, handler)===false){
            if(event.preventDefault) event.preventDefault();
              else event.returnValue = false;
            if(event.stopPropagation) event.stopPropagation();
            if(event.cancelBubble) event.cancelBubble = true;
          }
        }
      }
	}
  }
726662
protected boolean handleCtrlKeyDown(int keyCode)
	{
		if (!GuiScreen.isCtrlKeyDown())
			return false;

		switch (keyCode)
		{
			case Keyboard.KEY_LEFT:
				startSelecting();
				cursor.jumpToNextSpace(true);
				return true;
			case Keyboard.KEY_RIGHT:
				startSelecting();
				cursor.jumpToNextSpace(false);
				return true;
			case Keyboard.KEY_BACK:
				if (isEditable())
					this.deleteWord(true);
				return true;
			case Keyboard.KEY_END:
				startSelecting();
				cursor.jumpToEnd();
				return true;
			case Keyboard.KEY_A:
				selectingText = true;
				selectionCursor.jumpToStart();
				cursor.jumpToEnd();
				return true;
			case Keyboard.KEY_C:
				GuiScreen.setClipboardString(getSelectedText());
				return true;
			case Keyboard.KEY_V:
				if (isEditable())
					addText(GuiScreen.getClipboardString());
				return true;
			case Keyboard.KEY_X:
				GuiScreen.setClipboardString(getSelectedText());
				if (isEditable())
					addText("");
				return true;
			default:
				return false;
		}
	}
1163782
def _on_key_pressed(self, event):
        
        delete_request = event.key() in [QtCore.Qt.Key_Backspace,
                                         QtCore.Qt.Key_Delete]
        if event.text() or delete_request:
            cursor = self.editor.textCursor()
            if cursor.hasSelection():
                # change selection to encompass the whole scope.
                positions_to_check = cursor.selectionStart(), cursor.selectionEnd()
            else:
                positions_to_check = (cursor.position(), )
            for pos in positions_to_check:
                block = self.editor.document().findBlock(pos)
                th = TextBlockHelper()
                if th.is_fold_trigger(block) and th.is_collapsed(block):
                    self.toggle_fold_trigger(block)
                    if delete_request and cursor.hasSelection():
                        scope = FoldScope(self.find_parent_scope(block))
                        tc = TextHelper(self.editor).select_lines(*scope.get_range())
                        if tc.selectionStart() > cursor.selectionStart():
                            start = cursor.selectionStart()
                        else:
                            start = tc.selectionStart()
                        if tc.selectionEnd() < cursor.selectionEnd():
                            end = cursor.selectionEnd()
                        else:
                            end = tc.selectionEnd()
                        tc.setPosition(start)
                        tc.setPosition(end, tc.KeepAnchor)
                        self.editor.setTextCursor(tc)
168431
public void onKeyPress (KeyPressEvent event)
    {
        if (event.getCharCode() == KeyCodes.KEY_ESCAPE) {
            _onEscape.onClick(null);
        }
    }
1027829
def on_key(self, event):
        """"""

        if self.main_window.grid.actions.pasting and \
           event.GetKeyCode() == wx.WXK_ESCAPE:
            self.aborted = True

        event.Skip()
1237906
function _handleKeydown(e) {
            if (e.keyCode === KeyEvent.DOM_VK_ESCAPE) {
                e.stopPropagation();
                e.preventDefault();
                self.close();
            }
        }
1090649
function handleItemKeydown(e) {
    eventUtils.handleActionKeydown(e, () => {
        this.handleItemClick(e);
    });

    eventUtils.handleEscapeKeydown(e, () => {
        this.buttonEl.focus();
        this.setState('expanded', false);
    });
}
182785
def event_key_pressed(self, event):
        
        char = event.char
        if not char:
            return

        if char in string.ascii_letters:
            char = invert_shift(char)

        self.user_input_queue.put(char)

        # Don't insert the char in text widget, because it will be echoed
        # back from the machine!
        return "break"
510013
function eventKeyUp(e) {
  var keycode = ('which' in e) ? e.which : e.keyCode;
  keyUp(keycode);
}
986641
function(_event){
                var _code = _event.keyCode;
                if (_code === 65 && _event[SELECT_ALL_MODIFIER] && !_event.shiftKey && !_event.altKey || // Ctrl-A or Cmd-A
                    _code >= 37 && _code <= 40 || // arrow key
                    _event.ctrlKey && MAC && MAC_MOVE_KEYS.indexOf(_code) >= 0) {
                  if (!HAS_OWN_SELECTION[_event.target.tagName]) {
                    setTimeout(_dispatchIfChanged.bind(null, this), 0);
                  }
                }
            }
494486
def keyPressEvent(self, event):
        
        if event.key() == QtCore.Qt.Key_F5 or \
           (event.key() == QtCore.Qt.Key_E and \
            event.modifiers() == QtCore.Qt.ControlModifier):
            code = str(self._edit.toPlainText())
            scope = self.viewWidget().codeScope()
            
            exec code in scope, scope
        else:
            super(XScriptView, self).keyPressEvent(event)
1046615
function(e) {
      var t = this;

      // Make view options changes immediately on keydown
      // Note: Don't be so aggressive with monitor initParams, because that
      // could result in backend round-trips for each keystroke.
      setTimeout(function(){
        t.viewOptionBinder._onElChanged(e);
      },0);

      // Call the parent keydown
      t.onKeydown(e);
    }
697073
function onKeyEventTargetKeyDown(e) {
      var macroModeState = vimGlobalState.macroModeState;
      var lastChange = macroModeState.lastInsertModeChanges;
      var keyName = CodeMirror.keyName(e);
      function onKeyFound() {
        lastChange.changes.push(new InsertModeKey(keyName));
        return true;
      }
      if (keyName.indexOf('Delete') != -1 || keyName.indexOf('Backspace') != -1) {
        CodeMirror.lookupKey(keyName, ['vim-insert'], onKeyFound);
      }
    }
1134899
function onKeyDown( evt ) {
    switch ( evt.key ) {
    case 'Space':
        this.expanded = !this.expanded;
        evt.preventDefault();
        break;
    case 'Enter':
        this.action = this.value;
        break;
    case 'ArrowDown':
        selectNext.call( this );
        evt.preventDefault();
        break;
    case 'ArrowUp':
        selectPrev.call( this );
        evt.preventDefault();
        break;
    case 'Escape':
        if ( this.expanded ) {
            this.expanded = false;
            // Set the value as it was when we expanded the combo.
            this.value = this._valueWhenExpanded;
            evt.preventDefault();
        }
        break;
    default:
        // Do nothing.
    }
}
1053097
def on_sdl_keydown ( self, event ):
		""
		key = event.key.keysym.sym
		if key == SDLK_ESCAPE:
			self.running = False
843167
function keydown (event) {
    switch (event.keyCode) {
      case $mdConstant.KEY_CODE.LEFT_ARROW:
        event.preventDefault();
        incrementIndex(-1, true);
        break;
      case $mdConstant.KEY_CODE.RIGHT_ARROW:
        event.preventDefault();
        incrementIndex(1, true);
        break;
      case $mdConstant.KEY_CODE.SPACE:
      case $mdConstant.KEY_CODE.ENTER:
        event.preventDefault();
        if (!locked) select(ctrl.focusIndex);
        break;
      case $mdConstant.KEY_CODE.TAB:
        // On tabbing out of the tablist, reset hasFocus to reset ng-focused and
        // its md-focused class if the focused tab is not the active tab.
        if (ctrl.focusIndex !== ctrl.selectedIndex) {
          ctrl.focusIndex = ctrl.selectedIndex;
        }
        break;
    }
  }
1271322
function handleKeyEvent() {
        if (!$dropdown) {
            if (!SidebarView.isVisible()) {
                SidebarView.show();
            }

            $("#project-dropdown-toggle").trigger("click");

            $dropdown.focus();
            $links = $dropdown.find("a");
            // By default, select the most recent project (which is at the top of the list underneath Open Folder),
            // but if there are none, select Open Folder instead.
            $dropdownItem = $links.eq($links.length > 1 ? 1 : 0);
            $dropdownItem.addClass("selected");

            // If focusing the dropdown caused a modal bar to close, we need to refocus the dropdown
            window.setTimeout(function () {
                $dropdown.focus();
            }, 0);
        }
    }