Handle key events in a generic way
        supporting all window types.
18505
def key_event(self, key, action):
        
        if action == self.wnd.keys.ACTION_PRESS:
            if key == self.wnd.keys.SPACE:
                print("Space was pressed")

        if action == self.wnd.keys.ACTION_RELEASE:
            if key == self.wnd.keys.SPACE:
                print("Space was released")
300451
def event_trigger(self, event_type):
        """"""
        def callback(**kwargs):
            self.queued_events.append(event_type(**kwargs))
        return callback
884308
def keyPressEvent(self, event):
        """"""
        event, text, key, ctrl, shift = restore_keyevent(event)

        if key == Qt.Key_Slash and self.isVisible():
            self.show_find_widget.emit()
397863
def keyPressEvent(self, event):
        """"""
        if event == QKeySequence.Copy:
            self.copy()
        else:
            QTableView.keyPressEvent(self, event)
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);
        }
    }
1113466
def keyPressEvent(self, event):
        ""
        key = event.key()
        if key == Qt.Key_Escape:
            self.app.quit()
792359
private void keyTyped(KeyEvent event) {
        String text = event.getCharacter();
        int n = text.length();

        if(n == 0) {
            return;
        }

        view.replaceSelection(text);
    }
777621
def keyPressEvent(self, event):
        """"""
        if event.key() in (Qt.Key_Enter, Qt.Key_Return):
            self.clicked()
        elif event.key() == Qt.Key_F2:
            self.rename()
        elif event.key() == Qt.Key_Delete:
            self.delete()
        elif event.key() == Qt.Key_Backspace:
            self.go_to_parent_directory()
        else:
            QTreeView.keyPressEvent(self, event)
845743
def on_button(callback, args=(), buttons=(LEFT, MIDDLE, RIGHT, X, X2), types=(UP, DOWN, DOUBLE)):
    
    if not isinstance(buttons, (tuple, list)):
        buttons = (buttons,)
    if not isinstance(types, (tuple, list)):
        types = (types,)

    def handler(event):
        if isinstance(event, ButtonEvent):
            if event.event_type in types and event.button in buttons:
                callback(*args)
    _listener.add_handler(handler)
    return handler
200347
function(type) {
        var self = this,
            event,
            context,
            func,
            selector,
            win = $(window),
            doc = $(document);

        $.each(this.__events, function(i, value) {
            event = value[0];
            context = value[1];
            func = value[2];
            selector = value[3];

            // Determine the correct context
            if (self[context]) {
                context = self[context];

            } else if (context === 'window') {
                context = win;

            } else if (context === 'document') {
                context = doc;
            }

            // Ready events
            if (event === 'ready') {
                doc.ready(func);

            // Delegated events
            } else if (selector) {
                $(context)[type](event, selector, func);

            // Regular events
            } else {
                $(context)[type](event, func);
            }
        });
    }
670578
def set_event_handler(self, event, handler):
        """"""
        # QUESTION: Should we raise an exception if `event` is not in some
        # known event-type list?

        self._prepare_persistence_engine()

        callbacks = self._options.get('callbacks', {})
        callbacks[event] = handler
        self._options['callbacks'] = callbacks
295675
function(widget, target_name, view, template_arguments, callback_arguments) {

		return widget.handleEvent(
			callback_arguments.event_name,
			callback_arguments.event_object,
			target_name,
			view,
			template_arguments
		);

	}
40607
protected void onTimeKeyPressed(KeyUpEvent event) {

        switch (event.getNativeEvent().getKeyCode()) {
            case KeyCodes.KEY_CTRL:
            case KeyCodes.KEY_SHIFT:
            case KeyCodes.KEY_ALT:
            case KeyCodes.KEY_LEFT:
            case KeyCodes.KEY_RIGHT:
                break;
            case KeyCodes.KEY_ENTER:
                updateFromPicker();
                hidePopup();
                break;
            default:
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    public void execute() {

                        executeTimeAction();
                        fireChange(getValue(), false);
                    }
                });
                break;
        }
    }
278518
def process_events(self):
        """"""
        for event, args in iter_except(self.event_queue.popleft, IndexError):
            for callback in self.event_callbacks[event]:
                callback(*args)
378232
function(element, type, handler) {
    var types = type.split(' ');
    Hammer.utils.each(types, function(type){
      element.addEventListener(type, handler, false);
    });
  }
603959
def keyPressEvent(self, event):
        
        if event.key() in (Qt.Key_Enter, Qt.Key_Return):
            self.queryEntered.emit(self.query())
        
        super(XOrbQuickFilterWidget, self).keyPressEvent(event)
1035368
function (id, type, elem) {
            var self = this;
            $.each(elem.options.eventHandlers, function (event) {
                if (self.customEventHandlers[event] === undefined) self.customEventHandlers[event] = {};
                if (self.customEventHandlers[event][type] === undefined) self.customEventHandlers[event][type] = {};
                self.customEventHandlers[event][type][id] = elem;
            });
        }