Python pygame 模块,K_RCTRL 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用pygame.K_RCTRL

项目:python-fsm    作者:axelhj    | 项目源码 | 文件源码
def __init__(self, gameInstance):
        BaseController.__init__(self, gameInstance)

        keys = ( \
            pygame.K_LEFT, #left
            pygame.K_RIGHT,#right
            pygame.K_UP,   #acc
            pygame.K_DOWN, #brake
            pygame.K_LCTRL,#reverse
            pygame.K_r,    #restart
            #pygame.K_ESC,  #endGame
            pygame.K_RCTRL,
            #pygame.K_SPACE,
            \
            )

        self.keyToAction = dict()
        for key, action in zip(keys, self.gameInterface.gameInstance.actionsList):
            self.keyToAction.update({key: action})
        self.keyToAction[pygame.K_RCTRL] = self.keyToAction[pygame.K_LCTRL]
项目:Peppy    作者:project-owner    | 项目源码 | 文件源码
def handle_keyboard_event(self, event):
        """ Keyboard event handler. 

        Wraps keyboard events into user event. Exits upon Ctrl-C. 
        Distinguishes key up and key down.

        :param event: event to handle
        """        
        keys = pygame.key.get_pressed() 
        if (keys[pygame.K_LCTRL] or keys[pygame.K_RCTRL]) and event.key == pygame.K_c: 
            self.shutdown(event)
        elif event.type == pygame.KEYDOWN or event.type == pygame.KEYUP:
            if self.screensaver_dispatcher.saver_running:
                self.screensaver_dispatcher.cancel_screensaver()
                return
            self.handle_event(event)
            d = {}
            d[KEY_SUB_TYPE] = SUB_TYPE_KEYBOARD
            d[KEY_ACTION] = event.type
            d[KEY_KEYBOARD_KEY] = event.key
            event = pygame.event.Event(USER_EVENT_TYPE, **d)            
            pygame.event.post(event)
项目:myterminal    作者:graktung    | 项目源码 | 文件源码
def readChar():
    if event.key == pygame.K_BACKSPACE:
        return 'backspace'
    elif event.key == pygame.K_PAGEUP:
        return 'pageup'
    elif event.key == pygame.K_PAGEDOWN:
        return 'pagedown'
    elif event.key == pygame.K_TAB:
        return 'tab'
    elif event.key == pygame.K_RETURN:
        return 'enter'
    elif event.key == pygame.K_ESCAPE:
        return 'esc'
    elif event.key in (pygame.K_RSHIFT, pygame.K_LSHIFT):
        return 'shift'
    elif event.key in (pygame.K_RCTRL, pygame.K_LCTRL):
        return 'control'
    elif event.key == pygame.K_RIGHT:
        return 'kright'
    elif event.key == pygame.K_LEFT:
        return 'kleft'
    elif event.key == pygame.K_UP:
        return 'kup'
    elif event.key == pygame.K_DOWN:
        return 'kdown'
    elif event.key == pygame.K_CAPSLOCK:
        return None
    elif event.key == 282:
        return 'paste'
    elif event.key == 283:
        return 'begincur'
    elif event.key == 284:
        return 'endcur'
    elif event.key == 285:
        return 'delall'
    else:
        return event.unicode
项目:pyimgui    作者:swistakm    | 项目源码 | 文件源码
def process_event(self, event):
        # perf: local for faster access
        io = self.io

        if event.type == pygame.MOUSEMOTION:
            io.mouse_pos = event.pos

        if event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == 1:
                io.mouse_down[0] = 1
            if event.button == 2:
                io.mouse_down[1] = 1
            if event.button == 3:
                io.mouse_down[2] = 1

        if event.type == pygame.MOUSEBUTTONUP:
            if event.button == 1:
                io.mouse_down[0] = 0
            if event.button == 2:
                io.mouse_down[1] = 0
            if event.button == 3:
                io.mouse_down[2] = 0
            if event.button == 4:
                io.mouse_wheel = .5
            if event.button == 5:
                io.mouse_wheel = -.5

        if event.type == pygame.KEYDOWN:
            for char in event.unicode:
                code = ord(char)
                if 0 < code < 0x10000:
                    io.add_input_character(code)

            io.keys_down[event.key] = True

        if event.type == pygame.KEYUP:
            io.keys_down[event.key] = False

        if event.type in (pygame.KEYDOWN, pygame.KEYUP):
            io.key_ctrl = (
                io.keys_down[pygame.K_LCTRL] or
                io.keys_down[pygame.K_RCTRL]
            )

            io.key_alt = (
                io.keys_down[pygame.K_LALT] or
                io.keys_down[pygame.K_RALT]
            )

            io.key_shift = (
                io.keys_down[pygame.K_LSHIFT] or
                io.keys_down[pygame.K_RSHIFT]
            )

            io.key_super = (
                io.keys_down[pygame.K_LSUPER] or
                io.keys_down[pygame.K_LSUPER]
            )

        if event.type == pygame.VIDEORESIZE:
            io.display_size = event.size