Key handler for key presses.
978511
def on_press(self, window, key, scancode, action, mods):
        

        # controls for moving position
        if key == glfw.KEY_W:
            self.pos[0] -= self._pos_step  # dec x
        elif key == glfw.KEY_S:
            self.pos[0] += self._pos_step  # inc x
        elif key == glfw.KEY_A:
            self.pos[1] -= self._pos_step  # dec y
        elif key == glfw.KEY_D:
            self.pos[1] += self._pos_step  # inc y
        elif key == glfw.KEY_F:
            self.pos[2] -= self._pos_step  # dec z
        elif key == glfw.KEY_R:
            self.pos[2] += self._pos_step  # inc z

        # controls for moving orientation
        elif key == glfw.KEY_Z:
            drot = rotation_matrix(angle=0.1, direction=[1., 0., 0.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates x
        elif key == glfw.KEY_X:
            drot = rotation_matrix(angle=-0.1, direction=[1., 0., 0.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates x
        elif key == glfw.KEY_T:
            drot = rotation_matrix(angle=0.1, direction=[0., 1., 0.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates y
        elif key == glfw.KEY_G:
            drot = rotation_matrix(angle=-0.1, direction=[0., 1., 0.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates y
        elif key == glfw.KEY_C:
            drot = rotation_matrix(angle=0.1, direction=[0., 0., 1.])[:3, :3]
            self.rotation = self.rotation.dot(drot)  # rotates z
        elif key == glfw.KEY_V:
            drot = rotation_matrix(angle=-0.1, direction=[0., 0., 1.])[:3, :3]
            self.rotation = self.rotation.dot(drot)
1080275
def _process_keystroke_movement(self, inp, idx, offset):
        """"""
        term = self.term
        if inp in (u'y', u'k') or inp.code in (term.KEY_UP,):
            # scroll backward 1 line
            idx, offset = (idx, offset - self.screen.num_columns)
        elif inp in (u'e', u'j') or inp.code in (term.KEY_ENTER,
                                                 term.KEY_DOWN,):
            # scroll forward 1 line
            idx, offset = (idx, offset + self.screen.num_columns)
        elif inp in (u'f', u' ') or inp.code in (term.KEY_PGDOWN,):
            # scroll forward 1 page
            idx, offset = (idx + 1, offset)
        elif inp == u'b' or inp.code in (term.KEY_PGUP,):
            # scroll backward 1 page
            idx, offset = (max(0, idx - 1), offset)
        elif inp.code in (term.KEY_SDOWN,):
            # scroll forward 10 pages
            idx, offset = (max(0, idx + 10), offset)
        elif inp.code in (term.KEY_SUP,):
            # scroll forward 10 pages
            idx, offset = (max(0, idx - 10), offset)
        elif inp.code == term.KEY_HOME:
            # top
            idx, offset = (0, 0)
        elif inp.code == term.KEY_END:
            # bottom
            idx, offset = (self.last_page, 0)
        return idx, offset
200071
def keypress(self, viewer, event, data_x, data_y):
        """"""
        keyname = event.key
        chname = self.get_channel_name(viewer)
        self.logger.debug("key press (%s) in channel %s" % (
            keyname, chname))
        # TODO: keyboard accelerators to raise tabs need to be integrated into
        #   the desktop object
        if keyname == 'Z':
            self.ds.raise_tab('Zoom')
        ## elif keyname == 'T':
        ##     self.ds.raise_tab('Thumbs')
        elif keyname == 'I':
            self.ds.raise_tab('Info')
        elif keyname == 'H':
            self.ds.raise_tab('Header')
        elif keyname == 'C':
            self.ds.raise_tab('Contents')
        elif keyname == 'D':
            self.ds.raise_tab('Dialogs')
        elif keyname == 'F':
            self.build_fullscreen()
        elif keyname == 'f':
            self.toggle_fullscreen()
        elif keyname == 'm':
            self.maximize()
        elif keyname == '<':
            self.collapse_pane('left')
        elif keyname == '>':
            self.collapse_pane('right')
        elif keyname == 'n':
            self.next_channel()
        elif keyname == 'J':
            self.cycle_workspace_type()
        elif keyname == 'k':
            self.add_channel_auto()
        elif keyname == 'K':
            self.remove_channel_auto()
        elif keyname == 'f1':
            self.show_channel_names()
        ## elif keyname == 'escape':
        ##     self.reset_viewer()
        elif keyname in ('up',):
            self.prev_img()
        elif keyname in ('down',):
            self.next_img()
        elif keyname in ('left',):
            self.prev_channel()
        elif keyname in ('right',):
            self.next_channel()
        return True
259125
def handle_keypress(self):
        """"""
        if self.numpress == 2:
            self.sig_double_tab_pressed.emit(True)
        self.numpress = 0
702895
function(pressed, event) {
    var state = this.codes[event.keyCode];

    if (!state) {
      return;
    }

    this.states[state] = pressed;
    event.preventDefault && event.preventDefault();
    event.stopPropagation && event.stopPropagation();
  }
566419
def _on_key_pressed(self, event):
        
        if not event.isAccepted():
            if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
                cursor = self.editor.textCursor()
                pre, post = self._get_indent(cursor)
                cursor.beginEditBlock()
                cursor.insertText("%s\n%s" % (pre, post))

                # eats possible whitespaces
                cursor.movePosition(cursor.WordRight, cursor.KeepAnchor)
                txt = cursor.selectedText()
                if txt.startswith(' '):
                    new_txt = txt.replace(" ", '')
                    if len(txt) > len(new_txt):
                        cursor.insertText(new_txt)
                cursor.endEditBlock()
                event.accept()
279763
public void keyPress(String key, List<ModifierPressed> modifiers) {
    systemInputManager.keyPress(key, modifiers);
  }
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)
1113466
def keyPressEvent(self, event):
        ""
        key = event.key()
        if key == Qt.Key_Escape:
            self.app.quit()
1008141
def _bind_exit_key(self, key):
        """
        keyinfo = make_KeyPress_from_keydescr(key.lower()).tuple()
        self.exit_dispatch[keyinfo] = None
127870
def _onKeyDown(self, evt):
        """"""
        key = self._get_key(evt)
        evt.Skip()
        FigureCanvasBase.key_press_event(self, key, guiEvent=evt)
368795
def keypress(self, size, key):
        """"""
        key = self.__super.keypress(size, key)
        if key:
            key = self.unhandled_keys(size, key)
        return key
680493
def _on_enter(self, *args):
        """"""
        self.config(foreground=self._hover_color, cursor=self._cursor)
74396
function press(event) {
      if (event.keyCode === 39) {
        Components.Run.make(Components.Direction.resolve('>'));
      }

      if (event.keyCode === 37) {
        Components.Run.make(Components.Direction.resolve('<'));
      }
    }
606371
def on_press(callback, suppress=False):
    
    return hook(lambda e: e.event_type == KEY_UP or callback(e), suppress=suppress)
865873
def _handle_linux(self, keycode, character, press):
        """"""
        if character is None: return
        key = self._keyname(character, keycode)
        if key in self.MODIFIERNAMES:
            self._modifiers[self.MODIFIERNAMES[key]] = press
            self._realmodifiers[key] = press
        if press:
            self._output(type="keys", key=key, realkey=key)
        if press and key not in self.MODIFIERNAMES:
            modifier = "-".join(k for k in ["Ctrl", "Alt", "Shift", "Win"]
                                if self._modifiers[k])
            if modifier and modifier != "Shift": # Shift-X is not a combo
                realmodifier = "-".join(k for k, v in self._realmodifiers.items() if v)
                realkey = "%s-%s" % (realmodifier, key)
                key = "%s-%s" % (modifier, key)
                if DEBUG: print("Adding combo %s (real %s)" % (key.encode("utf-8"), realkey.encode("utf-8")))
                self._output(type="combos", key=key, realkey=realkey)
474321
def key_press_event(self, widget, event):
        
        # get keyname or keycode and translate to ginga standard
        # keyname =
        # keycode =
        keyname = ''  # self.transkey(keyname, keycode)
        self.logger.debug("key press event, key=%s" % (keyname))
        return self.make_ui_callback('key-press', keyname)