Build a key combination, such as:

        ctrl-t
358988
def build(cls, keys, down=None):
        
        codes = []
        for key in keys.split('-'):
            key = keycode(key)
            codes.append(key)

        events = []
        if down is None or down:
            for code in codes:
                events.append(cls(code, down=True))

        if down is None or not down:
            for code in reversed(codes):
                events.append(cls(code, down=False))
        return events
682945
def keys(self, namespace, prefix=None, limit=None, offset=None):
        """"""
        params = [namespace]
        query = 'SELECT key FROM gauged_keys WHERE namespace = %s'
        if prefix is not None:
            query += ' AND key LIKE %s'
            params.append(prefix + '%')
        if limit is not None:
            query += ' LIMIT %s'
            params.append(limit)
        if offset is not None:
            query += ' OFFSET %s'
            params.append(offset)
        cursor = self.cursor
        cursor.execute(query, params)
        return [key for key, in cursor]
1117387
def __generate_key(self, config):
        
        cwd = config.get('ssh_path', self._install_directory())
        if config.is_affirmative('create', default="yes"):
            if not os.path.exists(cwd):
                os.makedirs(cwd)
            if not os.path.exists(os.path.join(cwd, config.get('keyname'))):
                command = "ssh-keygen -t %(type)s -f %(keyname)s -N  " % config.to_dict()
                lib.call(command, cwd=cwd, output_log_level=logging.DEBUG)
        if not config.has('ssh_path'):
            config.set('ssh_path', cwd)
        config.set('ssh_key_path', os.path.join(config.get('ssh_path'), config.get('keyname')))
581735
def set_keys(self, keys):
        
        codes = {}
        for key in keys:
            parts = [k.strip().lower() for k in key.split("+")]
            code = KEYS.get(parts[-1])
            modifier = Qt.KeyboardModifiers()
            if code is None:
                raise KeyError("Invalid key code '{}'".format(key))
            if len(parts) > 1:
                for mod in parts[:-1]:
                    mod_code = MODIFIERS.get(mod)
                    if mod_code is None:
                        raise KeyError("Invalid key modifier '{}'"
                                       .format(mod_code))
                    modifier |= mod_code
            if code not in codes:
                codes[code] = []
            codes[code].append(modifier)
        self.codes = codes
56485
def translate_key_to_config(p_key):
    
    if len(p_key) > 1:
        key = p_key.capitalize()
        if key.startswith('Ctrl') or key.startswith('Meta'):
            key = key[0] + '-' + key[5:]
        key = '<' + key + '>'
    else:
        key = p_key

    return key
546439
def _key_tab(self):
        """"""
        if self.is_cursor_on_last_line():
            empty_line = not self.get_current_line_to_cursor().strip()
            if empty_line:
                self.stdkey_tab()
            else:
                self.show_code_completion()
102601
def key_press(self, key, x, y):
        ""
        if ord(key) == 27:
            # print "Escape!"
            if bool(glutLeaveMainLoop):
                glutLeaveMainLoop()
            else:
                raise Exception("Application quit")
252076
def command_getkeys(self, command, *args, encoding='utf-8'):
        """"""
        return self.execute(b'COMMAND', b'GETKEYS', command, *args,
                            encoding=encoding)
1222135
def typedkey(*args, **kwargs):
    """"""

    key = hashkey(*args, **kwargs)
    key += tuple(type(v) for v in args)
    key += tuple(type(v) for _, v in sorted(kwargs.items()))
    return key
128167
def _do_home_key(self, event=None, select=False):
        
        # get nb char to first significative char
        min_column = self.indenter_mode.min_column
        text = api.TextHelper(self).current_line_text()[min_column:]
        indent = len(text) - len(text.lstrip())
        delta = (self.textCursor().positionInBlock() - indent - min_column)
        cursor = self.textCursor()
        move = QtGui.QTextCursor.MoveAnchor
        if select:
            move = QtGui.QTextCursor.KeepAnchor
        if delta > 0:
            cursor.movePosition(QtGui.QTextCursor.Left, move, delta)
        else:
            cursor.movePosition(QtGui.QTextCursor.StartOfBlock, move)
            cursor.movePosition(QtGui.QTextCursor.Right, cursor.MoveAnchor, min_column)
        self.setTextCursor(cursor)
        if event:
            event.accept()
910447
def _process_keystroke_commands(self, inp):
        """"""
        if inp in (u'1', u'2'):
            # chose 1 or 2-character wide
            if int(inp) != self.screen.wide:
                self.screen.wide = int(inp)
                self.on_resize(None, None)
        elif inp in (u'_', u'-'):
            # adjust name length -2
            nlen = max(1, self.screen.style.name_len - 2)
            if nlen != self.screen.style.name_len:
                self.screen.style.name_len = nlen
                self.on_resize(None, None)
        elif inp in (u'+', u'='):
            # adjust name length +2
            nlen = min(self.term.width - 8, self.screen.style.name_len + 2)
            if nlen != self.screen.style.name_len:
                self.screen.style.name_len = nlen
                self.on_resize(None, None)
        elif inp == u'2' and self.screen.wide != 2:
            # change 2 or 1-cell wide view
            self.screen.wide = 2
            self.on_resize(None, None)
571560
def generate_key(filepath):
    ''' 
    '''
    fs = path.abspath(path.expanduser(filepath))
    with open(fs, 'wb') as outfile:
        outfile.write(Fernet.generate_key())
    chmod(fs, 0o400)
    return fs
1160237
def stdkey_home(self, shift, ctrl, prompt_pos=None):
        """"""
        move_mode = self.__get_move_mode(shift)
        if ctrl:
            self.moveCursor(QTextCursor.Start, move_mode)
        else:
            cursor = self.textCursor()
            if prompt_pos is None:
                start_position = self.get_position('sol')
            else:
                start_position = self.get_position(prompt_pos)
            text = self.get_text(start_position, 'eol')
            indent_pos = start_position+len(text)-len(text.lstrip())
            if cursor.position() != indent_pos:
                cursor.setPosition(indent_pos, move_mode)
            else:
                cursor.setPosition(start_position, move_mode)
            self.setTextCursor(cursor)
1072675
def Ctrl_V(self, delay=0):
        
        self._delay(delay)
        self.add(Command("KeyDown", 'KeyDown "%s", %s' % (BoardKey.Ctrl, 1)))
        self.add(Command("KeyPress", 'KeyPress "%s", %s' % (BoardKey.V, 1)))
        self.add(Command("KeyUp", 'KeyUp "%s", %s' % (BoardKey.Ctrl, 1)))
818795
def onKeyPressInCanvas(self, event):
        ''''''
        char_map = { 'w':'move 1', 'a':'strafe -1', 's':'move -1', 'd':'strafe 1', ' ':'jump 1' }
        keysym_map = { 'continuous': { 'Left':'turn -1', 'Right':'turn 1', 'Up':'pitch -1', 'Down':'pitch 1', 'Shift_L':'crouch 1',
                                       'Shift_R':'crouch 1', 
                                       '1':'hotbar.1 1', '2':'hotbar.2 1', '3':'hotbar.3 1', '4':'hotbar.4 1', '5':'hotbar.5 1',
                                       '6':'hotbar.6 1', '7':'hotbar.7 1', '8':'hotbar.8 1', '9':'hotbar.9 1' },
                       'discrete':   { 'Left':'turn -1', 'Right':'turn 1', 'Up':'move 1', 'Down':'move -1', 
                                       '1':'hotbar.1 1', '2':'hotbar.2 1', '3':'hotbar.3 1', '4':'hotbar.4 1', '5':'hotbar.5 1',
                                       '6':'hotbar.6 1', '7':'hotbar.7 1', '8':'hotbar.8 1', '9':'hotbar.9 1' } }
        if event.char == '/':
            self.command_entry.focus_set() # interlude to allow user to type command
        elif event.char.lower() in char_map:
            self.agent_host.sendCommand( char_map[ event.char.lower() ] )
        elif event.keysym in keysym_map[self.action_space]:
            self.agent_host.sendCommand( keysym_map[self.action_space][ event.keysym ] )
679938
def press_keys(self,characters=[]):
        """"""
        for character in characters:
            self.press_key(character)
        for character in characters:
            self.release_key(character)
1114592
def _do_home_key(self, event=None, select=False):
        
        # get nb char to first significative char
        delta = (self.textCursor().positionInBlock() -
                 TextHelper(self).line_indent())
        cursor = self.textCursor()
        move = QtGui.QTextCursor.MoveAnchor
        if select:
            move = QtGui.QTextCursor.KeepAnchor
        if delta > 0:
            cursor.movePosition(QtGui.QTextCursor.Left, move, delta)
        else:
            cursor.movePosition(QtGui.QTextCursor.StartOfBlock, move)
        self.setTextCursor(cursor)
        if event:
            event.accept()