()
Import pygame and define constants.
Import pygame and define constants.
Import pygame and define constants .
def _import_pygame():
    """Import pygame and define constants."""
    global pygame
    global KEY_TO_SCAN, MOD_TO_SCAN, KEY_TO_EASCII_NUM
    global KEY_TO_EASCII, SHIFT_KEY_TO_EASCII, CTRL_KEY_TO_EASCII, ALT_KEY_TO_EASCII

    import pygame

    # these are PC keyboard scancodes
    KEY_TO_SCAN = {
        # top row
        pygame.K_ESCAPE: scancode.ESCAPE, pygame.K_1: scancode.N1,
        pygame.K_2: scancode.N2, pygame.K_3: scancode.N3,
        pygame.K_4: scancode.N4, pygame.K_5: scancode.N5,
        pygame.K_6: scancode.N6, pygame.K_7: scancode.N7,
        pygame.K_8: scancode.N8, pygame.K_9: scancode.N9,
        pygame.K_0: scancode.N0, pygame.K_MINUS: scancode.MINUS,
        pygame.K_EQUALS: scancode.EQUALS,
        pygame.K_BACKSPACE: scancode.BACKSPACE,
        # row 1
        pygame.K_TAB: scancode.TAB, pygame.K_q: scancode.q,
        pygame.K_w: scancode.w, pygame.K_e: scancode.e, pygame.K_r: scancode.r,
        pygame.K_t: scancode.t, pygame.K_y: scancode.y, pygame.K_u: scancode.u,
        pygame.K_i: scancode.i, pygame.K_o: scancode.o, pygame.K_p: scancode.p,
        pygame.K_LEFTBRACKET: scancode.LEFTBRACKET,
        pygame.K_RIGHTBRACKET: scancode.RIGHTBRACKET,
        pygame.K_RETURN: scancode.RETURN, pygame.K_KP_ENTER: scancode.RETURN,
        # row 2
        pygame.K_RCTRL: scancode.CTRL, pygame.K_LCTRL: scancode.CTRL,
        pygame.K_a: scancode.a, pygame.K_s: scancode.s, pygame.K_d: scancode.d,
        pygame.K_f: scancode.f, pygame.K_g: scancode.g, pygame.K_h: scancode.h,
        pygame.K_j: scancode.j, pygame.K_k: scancode.k, pygame.K_l: scancode.l,
        pygame.K_SEMICOLON: scancode.SEMICOLON, pygame.K_QUOTE: scancode.QUOTE,
        pygame.K_BACKQUOTE: scancode.BACKQUOTE,
        # row 3
        pygame.K_LSHIFT: scancode.LSHIFT,
        pygame.K_BACKSLASH: scancode.BACKSLASH,
        pygame.K_z: scancode.z, pygame.K_x: scancode.x, pygame.K_c: scancode.c,
        pygame.K_v: scancode.v, pygame.K_b: scancode.b, pygame.K_n: scancode.n,
        pygame.K_m: scancode.m, pygame.K_COMMA: scancode.COMMA,
        pygame.K_PERIOD: scancode.PERIOD, pygame.K_SLASH: scancode.SLASH,
        pygame.K_RSHIFT: scancode.RSHIFT, pygame.K_PRINT: scancode.PRINT,
        pygame.K_SYSREQ: scancode.SYSREQ,
        pygame.K_LALT: scancode.ALT,
        # don't catch right-Alt as it may inhibit AltGr on Windows
        #pygame.K_RALT: scancode.ALT,
        pygame.K_SPACE: scancode.SPACE, pygame.K_CAPSLOCK: scancode.CAPSLOCK,
        # function key row
        pygame.K_F1: scancode.F1, pygame.K_F2: scancode.F2,
        pygame.K_F3: scancode.F3, pygame.K_F4: scancode.F4,
        pygame.K_F5: scancode.F5, pygame.K_F6: scancode.F6,
        pygame.K_F7: scancode.F7, pygame.K_F8: scancode.F8,
        pygame.K_F9: scancode.F9, pygame.K_F10: scancode.F10,
        pygame.K_F11: scancode.F11, pygame.K_F12: scancode.F12,
        # top middle
        pygame.K_NUMLOCK: scancode.NUMLOCK,
        pygame.K_SCROLLOCK: scancode.SCROLLOCK,
        # keypad
        pygame.K_KP7: scancode.KP7, pygame.K_HOME: scancode.HOME,
        pygame.K_KP8: scancode.KP8, pygame.K_UP: scancode.UP,
        pygame.K_KP9: scancode.KP9, pygame.K_PAGEUP: scancode.PAGEUP,
        pygame.K_KP_MINUS: scancode.KPMINUS,
        pygame.K_KP4: scancode.KP4, pygame.K_LEFT: scancode.LEFT,
        pygame.K_KP5: scancode.KP5,
        pygame.K_KP6: scancode.KP6, pygame.K_RIGHT: scancode.RIGHT,
        pygame.K_KP_PLUS: scancode.KPPLUS,
        pygame.K_KP1: scancode.KP1, pygame.K_END: scancode.END,
        pygame.K_KP2: scancode.KP2, pygame.K_DOWN: scancode.DOWN,
        pygame.K_KP3: scancode.KP3, pygame.K_PAGEDOWN: scancode.PAGEDOWN,
        pygame.K_KP0: scancode.KP0, pygame.K_INSERT: scancode.INSERT,
        # keypad dot, times, div, enter ?
        # various
        pygame.K_DELETE: scancode.DELETE,
        pygame.K_PAUSE: scancode.BREAK,
        pygame.K_BREAK: scancode.BREAK,
    }

    KEY_TO_EASCII = {
        pygame.K_F1: uea.F1,
        pygame.K_F2: uea.F2,
        pygame.K_F3: uea.F3,
        pygame.K_F4: uea.F4,
        pygame.K_F5: uea.F5,
        pygame.K_F6: uea.F6,
        pygame.K_F7: uea.F7,
        pygame.K_F8: uea.F8,
        pygame.K_F9: uea.F9,
        pygame.K_F10: uea.F10,
        pygame.K_F11: uea.F11,
        pygame.K_F12: uea.F12,
        pygame.K_HOME: uea.HOME,
        pygame.K_UP: uea.UP,
        pygame.K_PAGEUP: uea.PAGEUP,
        pygame.K_LEFT: uea.LEFT,
        pygame.K_RIGHT: uea.RIGHT,
        pygame.K_END: uea.END,
        pygame.K_DOWN: uea.DOWN,
        pygame.K_PAGEDOWN: uea.PAGEDOWN,
        pygame.K_ESCAPE: uea.ESCAPE,
        pygame.K_BACKSPACE: uea.BACKSPACE,
        pygame.K_TAB: uea.TAB,
        pygame.K_RETURN: uea.RETURN,
        pygame.K_KP_ENTER: uea.RETURN,
        pygame.K_SPACE: uea.SPACE,
        pygame.K_INSERT: uea.INSERT,
        pygame.K_DELETE: uea.DELETE,
    }

    SHIFT_KEY_TO_EASCII = {
        pygame.K_F1: uea.SHIFT_F1,
        pygame.K_F2: uea.SHIFT_F2,
        pygame.K_F3: uea.SHIFT_F3,
        pygame.K_F4: uea.SHIFT_F4,
        pygame.K_F5: uea.SHIFT_F5,
        pygame.K_F6: uea.SHIFT_F6,
        pygame.K_F7: uea.SHIFT_F7,
        pygame.K_F8: uea.SHIFT_F8,
        pygame.K_F9: uea.SHIFT_F9,
        pygame.K_F10: uea.SHIFT_F10,
        pygame.K_F11: uea.SHIFT_F11,
        pygame.K_F12: uea.SHIFT_F12,
        pygame.K_HOME: uea.SHIFT_HOME,
        pygame.K_UP: uea.SHIFT_UP,
        pygame.K_PAGEUP: uea.SHIFT_PAGEUP,
        pygame.K_LEFT: uea.SHIFT_LEFT,
        pygame.K_RIGHT: uea.SHIFT_RIGHT,
        pygame.K_END: uea.SHIFT_END,
        pygame.K_DOWN: uea.SHIFT_DOWN,
        pygame.K_PAGEDOWN: uea.SHIFT_PAGEDOWN,
        pygame.K_ESCAPE: uea.SHIFT_ESCAPE,
        pygame.K_BACKSPACE: uea.SHIFT_BACKSPACE,
        pygame.K_TAB: uea.SHIFT_TAB,
        pygame.K_RETURN: uea.SHIFT_RETURN,
        pygame.K_KP_ENTER: uea.SHIFT_RETURN,
        pygame.K_SPACE: uea.SHIFT_SPACE,
        pygame.K_INSERT: uea.SHIFT_INSERT,
        pygame.K_DELETE: uea.SHIFT_DELETE,
        pygame.K_KP5: uea.SHIFT_KP5,
    }

    CTRL_KEY_TO_EASCII = {
        pygame.K_F1: uea.CTRL_F1,
        pygame.K_F2: uea.CTRL_F2,
        pygame.K_F3: uea.CTRL_F3,
        pygame.K_F4: uea.CTRL_F4,
        pygame.K_F5: uea.CTRL_F5,
        pygame.K_F6: uea.CTRL_F6,
        pygame.K_F7: uea.CTRL_F7,
        pygame.K_F8: uea.CTRL_F8,
        pygame.K_F9: uea.CTRL_F9,
        pygame.K_F10: uea.CTRL_F10,
        pygame.K_F11: uea.CTRL_F11,
        pygame.K_F12: uea.CTRL_F12,
        pygame.K_HOME: uea.CTRL_HOME,
        pygame.K_PAGEUP: uea.CTRL_PAGEUP,
        pygame.K_LEFT: uea.CTRL_LEFT,
        pygame.K_RIGHT: uea.CTRL_RIGHT,
        pygame.K_END: uea.CTRL_END,
        pygame.K_PAGEDOWN: uea.CTRL_PAGEDOWN,
        pygame.K_ESCAPE: uea.CTRL_ESCAPE,
        pygame.K_BACKSPACE: uea.CTRL_BACKSPACE,
        pygame.K_TAB: uea.CTRL_TAB,
        pygame.K_RETURN: uea.CTRL_RETURN,
        pygame.K_KP_ENTER: uea.CTRL_RETURN,
        pygame.K_SPACE: uea.CTRL_SPACE,
        pygame.K_PRINT: uea.CTRL_PRINT,
        pygame.K_2: uea.CTRL_2,
        pygame.K_6: uea.CTRL_6,
        pygame.K_MINUS: uea.CTRL_MINUS,
    }

    ALT_KEY_TO_EASCII = {
        pygame.K_1: uea.ALT_1,
        pygame.K_2: uea.ALT_2,
        pygame.K_3: uea.ALT_3,
        pygame.K_4: uea.ALT_4,
        pygame.K_5: uea.ALT_5,
        pygame.K_6: uea.ALT_6,
        pygame.K_7: uea.ALT_7,
        pygame.K_8: uea.ALT_8,
        pygame.K_9: uea.ALT_9,
        pygame.K_0: uea.ALT_0,
        pygame.K_MINUS: uea.ALT_MINUS,
        pygame.K_EQUALS: uea.ALT_EQUALS,
        pygame.K_q: uea.ALT_q,
        pygame.K_w: uea.ALT_w,
        pygame.K_e: uea.ALT_e,
        pygame.K_r: uea.ALT_r,
        pygame.K_t: uea.ALT_t,
        pygame.K_y: uea.ALT_y,
        pygame.K_u: uea.ALT_u,
        pygame.K_i: uea.ALT_i,
        pygame.K_o: uea.ALT_o,
        pygame.K_p: uea.ALT_p,
        pygame.K_a: uea.ALT_a,
        pygame.K_s: uea.ALT_s,
        pygame.K_d: uea.ALT_d,
        pygame.K_f: uea.ALT_f,
        pygame.K_g: uea.ALT_g,
        pygame.K_h: uea.ALT_h,
        pygame.K_j: uea.ALT_j,
        pygame.K_k: uea.ALT_k,
        pygame.K_l: uea.ALT_l,
        pygame.K_z: uea.ALT_z,
        pygame.K_x: uea.ALT_x,
        pygame.K_c: uea.ALT_c,
        pygame.K_v: uea.ALT_v,
        pygame.K_b: uea.ALT_b,
        pygame.K_n: uea.ALT_n,
        pygame.K_m: uea.ALT_m,
        pygame.K_F1: uea.ALT_F1,
        pygame.K_F2: uea.ALT_F2,
        pygame.K_F3: uea.ALT_F3,
        pygame.K_F4: uea.ALT_F4,
        pygame.K_F5: uea.ALT_F5,
        pygame.K_F6: uea.ALT_F6,
        pygame.K_F7: uea.ALT_F7,
        pygame.K_F8: uea.ALT_F8,
        pygame.K_F9: uea.ALT_F9,
        pygame.K_F10: uea.ALT_F10,
        pygame.K_F11: uea.ALT_F11,
        pygame.K_F12: uea.ALT_F12,
        pygame.K_BACKSPACE: uea.ALT_BACKSPACE,
        pygame.K_TAB: uea.ALT_TAB,
        pygame.K_RETURN: uea.ALT_RETURN,
        pygame.K_KP_ENTER: uea.ALT_RETURN,
        pygame.K_SPACE: uea.ALT_SPACE,
        pygame.K_PRINT: uea.ALT_PRINT,
        pygame.K_KP5: uea.ALT_KP5,
    }

    MOD_TO_SCAN = {
        pygame.KMOD_LSHIFT: scancode.LSHIFT,
        pygame.KMOD_RSHIFT: scancode.RSHIFT,
        pygame.KMOD_LCTRL: scancode.CTRL,
        pygame.KMOD_RCTRL: scancode.CTRL,
        pygame.KMOD_LALT: scancode.ALT,
        # don't catch right-Alt as it may inhibit AltGr on Windows
        #pygame.KMOD_RALT: scancode.ALT,
    }

    KEY_TO_EASCII_NUM = {
        pygame.K_KP0: u'0',
        pygame.K_KP1: u'1',
        pygame.K_KP2: u'2',
        pygame.K_KP3: u'3',
        pygame.K_KP4: u'4',
        pygame.K_KP5: u'5',
        pygame.K_KP6: u'6',
        pygame.K_KP7: u'7',
        pygame.K_KP8: u'8',
        pygame.K_KP9: u'9',
    }
def _import_pygame ( ) : global pygame global KEY_TO_SCAN , MOD_TO_SCAN , KEY_TO_EASCII_NUM global KEY_TO_EASCII , SHIFT_KEY_TO_EASCII , CTRL_KEY_TO_EASCII , ALT_KEY_TO_EASCII import pygame # these are PC keyboard scancodes KEY_TO_SCAN = { # top row pygame . K_ESCAPE : scancode . ESCAPE , pygame . K_1 : scancode . N1 , pygame . K_2 : scancode . N2 , pygame . K_3 : scancode . N3 , pygame . K_4 : scancode . N4 , pygame . K_5 : scancode . N5 , pygame . K_6 : scancode . N6 , pygame . K_7 : scancode . N7 , pygame . K_8 : scancode . N8 , pygame . K_9 : scancode . N9 , pygame . K_0 : scancode . N0 , pygame . K_MINUS : scancode . MINUS , pygame . K_EQUALS : scancode . EQUALS , pygame . K_BACKSPACE : scancode . BACKSPACE , # row 1 pygame . K_TAB : scancode . TAB , pygame . K_q : scancode . q , pygame . K_w : scancode . w , pygame . K_e : scancode . e , pygame . K_r : scancode . r , pygame . K_t : scancode . t , pygame . K_y : scancode . y , pygame . K_u : scancode . u , pygame . K_i : scancode . i , pygame . K_o : scancode . o , pygame . K_p : scancode . p , pygame . K_LEFTBRACKET : scancode . LEFTBRACKET , pygame . K_RIGHTBRACKET : scancode . RIGHTBRACKET , pygame . K_RETURN : scancode . RETURN , pygame . K_KP_ENTER : scancode . RETURN , # row 2 pygame . K_RCTRL : scancode . CTRL , pygame . K_LCTRL : scancode . CTRL , pygame . K_a : scancode . a , pygame . K_s : scancode . s , pygame . K_d : scancode . d , pygame . K_f : scancode . f , pygame . K_g : scancode . g , pygame . K_h : scancode . h , pygame . K_j : scancode . j , pygame . K_k : scancode . k , pygame . K_l : scancode . l , pygame . K_SEMICOLON : scancode . SEMICOLON , pygame . K_QUOTE : scancode . QUOTE , pygame . K_BACKQUOTE : scancode . BACKQUOTE , # row 3 pygame . K_LSHIFT : scancode . LSHIFT , pygame . K_BACKSLASH : scancode . BACKSLASH , pygame . K_z : scancode . z , pygame . K_x : scancode . x , pygame . K_c : scancode . c , pygame . K_v : scancode . v , pygame . K_b : scancode . b , pygame . K_n : scancode . n , pygame . K_m : scancode . m , pygame . K_COMMA : scancode . COMMA , pygame . K_PERIOD : scancode . PERIOD , pygame . K_SLASH : scancode . SLASH , pygame . K_RSHIFT : scancode . RSHIFT , pygame . K_PRINT : scancode . PRINT , pygame . K_SYSREQ : scancode . SYSREQ , pygame . K_LALT : scancode . ALT , # don't catch right-Alt as it may inhibit AltGr on Windows #pygame.K_RALT: scancode.ALT, pygame . K_SPACE : scancode . SPACE , pygame . K_CAPSLOCK : scancode . CAPSLOCK , # function key row pygame . K_F1 : scancode . F1 , pygame . K_F2 : scancode . F2 , pygame . K_F3 : scancode . F3 , pygame . K_F4 : scancode . F4 , pygame . K_F5 : scancode . F5 , pygame . K_F6 : scancode . F6 , pygame . K_F7 : scancode . F7 , pygame . K_F8 : scancode . F8 , pygame . K_F9 : scancode . F9 , pygame . K_F10 : scancode . F10 , pygame . K_F11 : scancode . F11 , pygame . K_F12 : scancode . F12 , # top middle pygame . K_NUMLOCK : scancode . NUMLOCK , pygame . K_SCROLLOCK : scancode . SCROLLOCK , # keypad pygame . K_KP7 : scancode . KP7 , pygame . K_HOME : scancode . HOME , pygame . K_KP8 : scancode . KP8 , pygame . K_UP : scancode . UP , pygame . K_KP9 : scancode . KP9 , pygame . K_PAGEUP : scancode . PAGEUP , pygame . K_KP_MINUS : scancode . KPMINUS , pygame . K_KP4 : scancode . KP4 , pygame . K_LEFT : scancode . LEFT , pygame . K_KP5 : scancode . KP5 , pygame . K_KP6 : scancode . KP6 , pygame . K_RIGHT : scancode . RIGHT , pygame . K_KP_PLUS : scancode . KPPLUS , pygame . K_KP1 : scancode . KP1 , pygame . K_END : scancode . END , pygame . K_KP2 : scancode . KP2 , pygame . K_DOWN : scancode . DOWN , pygame . K_KP3 : scancode . KP3 , pygame . K_PAGEDOWN : scancode . PAGEDOWN , pygame . K_KP0 : scancode . KP0 , pygame . K_INSERT : scancode . INSERT , # keypad dot, times, div, enter ? # various pygame . K_DELETE : scancode . DELETE , pygame . K_PAUSE : scancode . BREAK , pygame . K_BREAK : scancode . BREAK , } KEY_TO_EASCII = { pygame . K_F1 : uea . F1 , pygame . K_F2 : uea . F2 , pygame . K_F3 : uea . F3 , pygame . K_F4 : uea . F4 , pygame . K_F5 : uea . F5 , pygame . K_F6 : uea . F6 , pygame . K_F7 : uea . F7 , pygame . K_F8 : uea . F8 , pygame . K_F9 : uea . F9 , pygame . K_F10 : uea . F10 , pygame . K_F11 : uea . F11 , pygame . K_F12 : uea . F12 , pygame . K_HOME : uea . HOME , pygame . K_UP : uea . UP , pygame . K_PAGEUP : uea . PAGEUP , pygame . K_LEFT : uea . LEFT , pygame . K_RIGHT : uea . RIGHT , pygame . K_END : uea . END , pygame . K_DOWN : uea . DOWN , pygame . K_PAGEDOWN : uea . PAGEDOWN , pygame . K_ESCAPE : uea . ESCAPE , pygame . K_BACKSPACE : uea . BACKSPACE , pygame . K_TAB : uea . TAB , pygame . K_RETURN : uea . RETURN , pygame . K_KP_ENTER : uea . RETURN , pygame . K_SPACE : uea . SPACE , pygame . K_INSERT : uea . INSERT , pygame . K_DELETE : uea . DELETE , } SHIFT_KEY_TO_EASCII = { pygame . K_F1 : uea . SHIFT_F1 , pygame . K_F2 : uea . SHIFT_F2 , pygame . K_F3 : uea . SHIFT_F3 , pygame . K_F4 : uea . SHIFT_F4 , pygame . K_F5 : uea . SHIFT_F5 , pygame . K_F6 : uea . SHIFT_F6 , pygame . K_F7 : uea . SHIFT_F7 , pygame . K_F8 : uea . SHIFT_F8 , pygame . K_F9 : uea . SHIFT_F9 , pygame . K_F10 : uea . SHIFT_F10 , pygame . K_F11 : uea . SHIFT_F11 , pygame . K_F12 : uea . SHIFT_F12 , pygame . K_HOME : uea . SHIFT_HOME , pygame . K_UP : uea . SHIFT_UP , pygame . K_PAGEUP : uea . SHIFT_PAGEUP , pygame . K_LEFT : uea . SHIFT_LEFT , pygame . K_RIGHT : uea . SHIFT_RIGHT , pygame . K_END : uea . SHIFT_END , pygame . K_DOWN : uea . SHIFT_DOWN , pygame . K_PAGEDOWN : uea . SHIFT_PAGEDOWN , pygame . K_ESCAPE : uea . SHIFT_ESCAPE , pygame . K_BACKSPACE : uea . SHIFT_BACKSPACE , pygame . K_TAB : uea . SHIFT_TAB , pygame . K_RETURN : uea . SHIFT_RETURN , pygame . K_KP_ENTER : uea . SHIFT_RETURN , pygame . K_SPACE : uea . SHIFT_SPACE , pygame . K_INSERT : uea . SHIFT_INSERT , pygame . K_DELETE : uea . SHIFT_DELETE , pygame . K_KP5 : uea . SHIFT_KP5 , } CTRL_KEY_TO_EASCII = { pygame . K_F1 : uea . CTRL_F1 , pygame . K_F2 : uea . CTRL_F2 , pygame . K_F3 : uea . CTRL_F3 , pygame . K_F4 : uea . CTRL_F4 , pygame . K_F5 : uea . CTRL_F5 , pygame . K_F6 : uea . CTRL_F6 , pygame . K_F7 : uea . CTRL_F7 , pygame . K_F8 : uea . CTRL_F8 , pygame . K_F9 : uea . CTRL_F9 , pygame . K_F10 : uea . CTRL_F10 , pygame . K_F11 : uea . CTRL_F11 , pygame . K_F12 : uea . CTRL_F12 , pygame . K_HOME : uea . CTRL_HOME , pygame . K_PAGEUP : uea . CTRL_PAGEUP , pygame . K_LEFT : uea . CTRL_LEFT , pygame . K_RIGHT : uea . CTRL_RIGHT , pygame . K_END : uea . CTRL_END , pygame . K_PAGEDOWN : uea . CTRL_PAGEDOWN , pygame . K_ESCAPE : uea . CTRL_ESCAPE , pygame . K_BACKSPACE : uea . CTRL_BACKSPACE , pygame . K_TAB : uea . CTRL_TAB , pygame . K_RETURN : uea . CTRL_RETURN , pygame . K_KP_ENTER : uea . CTRL_RETURN , pygame . K_SPACE : uea . CTRL_SPACE , pygame . K_PRINT : uea . CTRL_PRINT , pygame . K_2 : uea . CTRL_2 , pygame . K_6 : uea . CTRL_6 , pygame . K_MINUS : uea . CTRL_MINUS , } ALT_KEY_TO_EASCII = { pygame . K_1 : uea . ALT_1 , pygame . K_2 : uea . ALT_2 , pygame . K_3 : uea . ALT_3 , pygame . K_4 : uea . ALT_4 , pygame . K_5 : uea . ALT_5 , pygame . K_6 : uea . ALT_6 , pygame . K_7 : uea . ALT_7 , pygame . K_8 : uea . ALT_8 , pygame . K_9 : uea . ALT_9 , pygame . K_0 : uea . ALT_0 , pygame . K_MINUS : uea . ALT_MINUS , pygame . K_EQUALS : uea . ALT_EQUALS , pygame . K_q : uea . ALT_q , pygame . K_w : uea . ALT_w , pygame . K_e : uea . ALT_e , pygame . K_r : uea . ALT_r , pygame . K_t : uea . ALT_t , pygame . K_y : uea . ALT_y , pygame . K_u : uea . ALT_u , pygame . K_i : uea . ALT_i , pygame . K_o : uea . ALT_o , pygame . K_p : uea . ALT_p , pygame . K_a : uea . ALT_a , pygame . K_s : uea . ALT_s , pygame . K_d : uea . ALT_d , pygame . K_f : uea . ALT_f , pygame . K_g : uea . ALT_g , pygame . K_h : uea . ALT_h , pygame . K_j : uea . ALT_j , pygame . K_k : uea . ALT_k , pygame . K_l : uea . ALT_l , pygame . K_z : uea . ALT_z , pygame . K_x : uea . ALT_x , pygame . K_c : uea . ALT_c , pygame . K_v : uea . ALT_v , pygame . K_b : uea . ALT_b , pygame . K_n : uea . ALT_n , pygame . K_m : uea . ALT_m , pygame . K_F1 : uea . ALT_F1 , pygame . K_F2 : uea . ALT_F2 , pygame . K_F3 : uea . ALT_F3 , pygame . K_F4 : uea . ALT_F4 , pygame . K_F5 : uea . ALT_F5 , pygame . K_F6 : uea . ALT_F6 , pygame . K_F7 : uea . ALT_F7 , pygame . K_F8 : uea . ALT_F8 , pygame . K_F9 : uea . ALT_F9 , pygame . K_F10 : uea . ALT_F10 , pygame . K_F11 : uea . ALT_F11 , pygame . K_F12 : uea . ALT_F12 , pygame . K_BACKSPACE : uea . ALT_BACKSPACE , pygame . K_TAB : uea . ALT_TAB , pygame . K_RETURN : uea . ALT_RETURN , pygame . K_KP_ENTER : uea . ALT_RETURN , pygame . K_SPACE : uea . ALT_SPACE , pygame . K_PRINT : uea . ALT_PRINT , pygame . K_KP5 : uea . ALT_KP5 , } MOD_TO_SCAN = { pygame . KMOD_LSHIFT : scancode . LSHIFT , pygame . KMOD_RSHIFT : scancode . RSHIFT , pygame . KMOD_LCTRL : scancode . CTRL , pygame . KMOD_RCTRL : scancode . CTRL , pygame . KMOD_LALT : scancode . ALT , # don't catch right-Alt as it may inhibit AltGr on Windows #pygame.KMOD_RALT: scancode.ALT, } KEY_TO_EASCII_NUM = { pygame . K_KP0 : u'0' , pygame . K_KP1 : u'1' , pygame . K_KP2 : u'2' , pygame . K_KP3 : u'3' , pygame . K_KP4 : u'4' , pygame . K_KP5 : u'5' , pygame . K_KP6 : u'6' , pygame . K_KP7 : u'7' , pygame . K_KP8 : u'8' , pygame . K_KP9 : u'9' , }