(self, mod, c)
Translate kaa's key value to curses keycode
Translate kaa's key value to curses keycode
Translate kaa s key value to curses keycode
def translate_key(self, mod, c):
        """Translate kaa's key value to curses keycode"""

        alt = keyboard.alt in mod
        ctrl = keyboard.ctrl in mod
        shift = keyboard.shift in mod

        if alt:
            meta = '\x1b'
        else:
            meta = ''

        if isinstance(c, str):
            if shift:
                raise KaaError(
                    'Cannot use shift key for character: {!r}'.format((mod, c)))
            if ctrl:
                c = c.upper()
                if not (0x40 <= ord(c) <= 0x5f):
                    raise KaaError(
                        'Cannot use control key for character: {!r}'.format((mod, c)))
                return meta + chr(ord(c) - 0x40)
            else:
                return meta + c
        else:
            ret = keydef.keyfromname(c, ctrl, shift)
            if ret is None:
                raise KaaError(
                    'Cannot convert character: {!r}'.format((mod, c)))

            return [ret] if not meta else [meta, ret]
def translate_key ( self , mod , c ) : alt = keyboard . alt in mod ctrl = keyboard . ctrl in mod shift = keyboard . shift in mod if alt : meta = '\x1b' else : meta = '' if isinstance ( c , str ) : if shift : raise KaaError ( 'Cannot use shift key for character: {!r}' . format ( ( mod , c ) ) ) if ctrl : c = c . upper ( ) if not ( 0x40 <= ord ( c ) <= 0x5f ) : raise KaaError ( 'Cannot use control key for character: {!r}' . format ( ( mod , c ) ) ) return meta + chr ( ord ( c ) - 0x40 ) else : return meta + c else : ret = keydef . keyfromname ( c , ctrl , shift ) if ret is None : raise KaaError ( 'Cannot convert character: {!r}' . format ( ( mod , c ) ) ) return [ ret ] if not meta else [ meta , ret ]