Every line of 'pygame enter key' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
95 def checkForKeyPress(): 96 if len(pygame.event.get(QUIT)) > 0: 97 terminate() 98 99 keyUpEvents = pygame.event.get(KEYUP) 100 if len(keyUpEvents) == 0: 101 return None 102 if keyUpEvents[0].key == K_ESCAPE: 103 terminate() 104 return keyUpEvents[0].key
97 def onPress(self): 98 if self.c.onEnter is not None: 99 self.c.onEnter()
81 def pressTest(self, key): 82 print( "-> Pressing " + key.upper() )
146 def key_down(self, key): 147 if key in self.map: 148 self.velocity = V2((3 / self.scale, 0) if key in self.map[:2] else (0, 3 / self.scale)).elementwise() * ( 149 (self.map.index(key) not in (1, 2)) * 2 - 1)
44 def _read_key(self): 45 ch = self.stdscr.getch() 46 if ch > 0 and ch != self.last_ch: 47 key = chr(ch) 48 if key in self.key2actions: 49 self.key2actions[key].func() 50 self.last_ch = ch
92 def on_key_press(self, k, mod): 93 numbers = [key._1, key._2, key._3, key._4, key._5, 94 key._6, key._7, key._8, key._9, key._0 ] 95 if k == key.T: 96 # track if the user wants to translate origin to the current 97 # skeleton position 98 # if you run two walk left animations without translation 99 # you will see a player move left, go to the origin and move 100 # left again. 101 # if you use translation, the player will just move left twice 102 # as far 103 self.translate = not self.translate 104 if k == key.F: 105 # track if the user wants to run the animation normal or flipped 106 # if the animation is a guy walking left, when flipped it will 107 # walk right 108 self.flipped = not self.flipped 109 self.skin.flip() 110 111 if k in numbers: 112 # find which animation the user wants to run 113 n = numbers.index(k) 114 if n < len(self.anims): 115 # kill current animations 116 self.skin.stop() 117 anim = self.anims[n] 118 # if we want to run the animation flipped, we create 119 # the flipped version 120 if self.flipped: 121 anim = anim.flipped() 122 # we run the animation on the skin using the Animate action. 123 # remember that Animate is a cocos action, so you can do 124 # any action stuff you want with them. 125 # you just have to say which animation you want to use 126 # and what kind of translation 127 self.skin.do( Animate( anim , recenter_x=self.translate ) )
17 def keypress(key): 18 #keyboard.press(key) 19 #keyboard.release(key) 20 os.system("xdotool key %s" % key)
231 def handle_event(self, e): 232 """ Map a pygame event to nuklear input. """ 233 234 if e.type == pygame.KEYDOWN or e.type == pygame.KEYUP: 235 consumed = False 236 down = e.type == pygame.KEYDOWN 237 for nk_key in NkPygame.KEYMAP.map_key(e.key, e.mod): 238 lib.nk_input_key(self.ctx, nk_key, down) 239 consumed = True 240 if not consumed and down and len(e.unicode) == 1: 241 # Note: should pass unicode directly, but need to 242 # convert wchar_t (which is what cffi converts to) 243 # to int or char[4]. wchar_t is 2 bytes on windows 244 # for utf-16 245 if unicodedata.category(e.unicode)[0] != "C": 246 char = str(e.unicode) 247 if len(char) == 1: 248 lib.nk_input_char(self.ctx, str(e.unicode)) 249 elif e.type == pygame.MOUSEBUTTONDOWN or e.type == pygame.MOUSEBUTTONUP: 250 down = e.type == pygame.MOUSEBUTTONDOWN 251 button = lib.NK_BUTTON_LEFT 252 if e.button == 1: 253 button = lib.NK_BUTTON_LEFT 254 elif e.button == 3: 255 button = lib.NK_BUTTON_RIGHT 256 lib.nk_input_button(self.ctx, button, e.pos[0], e.pos[1], down) 257 elif e.type == pygame.MOUSEMOTION: 258 lib.nk_input_motion(self.ctx, e.pos[0], e.pos[1])
11 def handle_keys(key, game_state): 12 if game_state == GameStates.PLAYERS_TURN: 13 return handle_player_turn_keys(key) 14 elif game_state == GameStates.PLAYER_DEAD: 15 return handle_player_dead_keys(key) 16 elif game_state == GameStates.TARGETING: 17 return handle_targeting_keys(key) 18 elif game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY): 19 return handle_inventory_keys(key) 20 elif game_state == GameStates.LEVEL_UP: 21 return handle_level_up_menu(key) 22 elif game_state == GameStates.CHARACTER_SCREEN: 23 return handle_character_screen(key) 24 25 return {}
14 def handle_keys(key_event, game_state): 15 # logging.debug(f'Handling {key}') 16 17 # Inputs valid in all game states # 18 key = key_event.sym 19 mod = key_event.mod 20 21 # if key.vk == tcod.KEY_ENTER and key.lalt: 22 # # Alt+Enter: toggle full screen 23 # return {'fullscreen': True} 24 # elif key.vk == tcod.KEY_ESCAPE: 25 # # Exit the game 26 # return {'exit': True} 27 # elif chr(key.c) == keys_dict['manual'] and key.shift: 28 # return {'manual': True} 29 # elif chr(key.c) == keys_dict['debug'] and key.lalt: 30 # return {'debug': True} 31 32 33 # Game state specific inputs # 34 # if game_state in [GameState.PLAYERS_TURN, GameState.PLAYER_RESTING, GameState.CURSOR_ACTIVE, GameState.CURSOR_TARGETING]: 35 # return handle_player_turn_keys(key) 36 # elif game_state == GameState.PLAYER_DEAD: 37 # return handle_player_dead_keys(key) 38 # elif game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY, GameStates.SHOW_ITEM): 39 # return handle_menu_keys(key) 40 # elif game_state == GameStates.TARGETING: 41 # results = dict(handle_targeting_keys()) 42 43 return {}