Python pygame.KMOD_CTRL Examples
The following are 11
code examples of pygame.KMOD_CTRL().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygame
, or try the search function
.
Example #1
Source File: _utils.py From pygame-menu with MIT License | 6 votes |
def keydown_mod_ctrl(key, inlist=True): """ Create a mod ctrl keydown event (Ctrl+Key). :param key: Key to press :type key: int :param inlist: Return event in a list :type inlist: bool :return: Event :rtype: :py:class:`pygame.event.Event` """ pygame.key.set_mods(pygame.KMOD_CTRL) event_obj = pygame.event.Event(pygame.KEYDOWN, {'key': key, 'test': True, }) if inlist: event_obj = [event_obj] return event_obj
Example #2
Source File: window_pygame.py From Tickeys-linux with MIT License | 6 votes |
def _pygame_update_modifiers(self, mods=None): # Available mod, from dir(pygame) # 'KMOD_ALT', 'KMOD_CAPS', 'KMOD_CTRL', 'KMOD_LALT', # 'KMOD_LCTRL', 'KMOD_LMETA', 'KMOD_LSHIFT', 'KMOD_META', # 'KMOD_MODE', 'KMOD_NONE' if mods is None: mods = pygame.key.get_mods() self._modifiers = [] if mods & (pygame.KMOD_SHIFT | pygame.KMOD_LSHIFT): self._modifiers.append('shift') if mods & (pygame.KMOD_ALT | pygame.KMOD_LALT): self._modifiers.append('alt') if mods & (pygame.KMOD_CTRL | pygame.KMOD_LCTRL): self._modifiers.append('ctrl') if mods & (pygame.KMOD_META | pygame.KMOD_LMETA): self._modifiers.append('meta')
Example #3
Source File: window_pygame.py From Tickeys-linux with MIT License | 6 votes |
def _pygame_update_modifiers(self, mods=None): # Available mod, from dir(pygame) # 'KMOD_ALT', 'KMOD_CAPS', 'KMOD_CTRL', 'KMOD_LALT', # 'KMOD_LCTRL', 'KMOD_LMETA', 'KMOD_LSHIFT', 'KMOD_META', # 'KMOD_MODE', 'KMOD_NONE' if mods is None: mods = pygame.key.get_mods() self._modifiers = [] if mods & (pygame.KMOD_SHIFT | pygame.KMOD_LSHIFT): self._modifiers.append('shift') if mods & (pygame.KMOD_ALT | pygame.KMOD_LALT): self._modifiers.append('alt') if mods & (pygame.KMOD_CTRL | pygame.KMOD_LCTRL): self._modifiers.append('ctrl') if mods & (pygame.KMOD_META | pygame.KMOD_LMETA): self._modifiers.append('meta')
Example #4
Source File: window.py From moderngl-window with MIT License | 5 votes |
def _handle_mods(self) -> None: """Update key mods""" mods = pygame.key.get_mods() self._modifiers.shift = mods & pygame.KMOD_SHIFT self._modifiers.ctrl = mods & pygame.KMOD_CTRL self._modifiers.alt = mods & pygame.KMOD_ALT
Example #5
Source File: booth.py From pibooth with MIT License | 5 votes |
def find_fullscreen_event(self, events): """Return the first found event if found in the list. """ for event in events: if event.type == pygame.KEYDOWN and \ event.key == pygame.K_f and pygame.key.get_mods() & pygame.KMOD_CTRL: return event return None
Example #6
Source File: booth.py From pibooth with MIT License | 5 votes |
def find_print_event(self, events): """Return the first found event if found in the list. """ for event in events: if event.type == pygame.KEYDOWN and event.key == pygame.K_e\ and pygame.key.get_mods() & pygame.KMOD_CTRL: return event if event.type == pygame.MOUSEBUTTONUP and event.button in (1, 2, 3): # Don't consider the mouse wheel (button 4 & 5): rect = self._window.get_rect() if pygame.Rect(rect.width // 2, 0, rect.width // 2, rect.height).collidepoint(event.pos): return event if event.type == BUTTONDOWN and event.printer: return event return None
Example #7
Source File: key_test.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
def test_set_and_get_mods(self): pygame.key.set_mods(pygame.KMOD_CTRL) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL) pygame.key.set_mods(pygame.KMOD_ALT) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_ALT) pygame.key.set_mods(pygame.KMOD_CTRL | pygame.KMOD_ALT) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL | pygame.KMOD_ALT)
Example #8
Source File: key_test.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
def test_set_and_get_mods(self): pygame.key.set_mods(pygame.KMOD_CTRL) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL) pygame.key.set_mods(pygame.KMOD_ALT) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_ALT) pygame.key.set_mods(pygame.KMOD_CTRL | pygame.KMOD_ALT) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL | pygame.KMOD_ALT)
Example #9
Source File: key_test.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
def test_set_and_get_mods(self): pygame.key.set_mods(pygame.KMOD_CTRL) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL) pygame.key.set_mods(pygame.KMOD_ALT) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_ALT) pygame.key.set_mods(pygame.KMOD_CTRL | pygame.KMOD_ALT) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL | pygame.KMOD_ALT)
Example #10
Source File: key_test.py From fxxkpython with GNU General Public License v3.0 | 5 votes |
def test_set_and_get_mods(self): pygame.key.set_mods(pygame.KMOD_CTRL) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL) pygame.key.set_mods(pygame.KMOD_ALT) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_ALT) pygame.key.set_mods(pygame.KMOD_CTRL | pygame.KMOD_ALT) self.assertEqual(pygame.key.get_mods(), pygame.KMOD_CTRL | pygame.KMOD_ALT)
Example #11
Source File: creeps.py From code-for-blog with The Unlicense | 4 votes |
def run(self): # The main game loop # while True: # Limit frame speed to 30 FPS # time_passed = self.clock.tick(30) #~ time_passed = self.clock.tick() #~ print time_passed # If too long has passed between two frames, don't # update (the game must have been suspended for some # reason, and we don't want it to "jump forward" # suddenly) # if time_passed > 100: continue for event in pygame.event.get(): if event.type == pygame.QUIT: self.quit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: self.paused = not self.paused elif event.key == pygame.K_g: if pygame.key.get_mods() & pygame.KMOD_CTRL: self.options['draw_grid'] = not self.options['draw_grid'] elif ( event.type == pygame.MOUSEBUTTONDOWN and event.button == 1): for creep in self.creeps: creep.mouse_click_event(event.pos) if not self.paused: msg1 = 'Creeps: %d' % len(self.creeps) msg2 = '' self.mboard_text = [msg1, msg2] self.creep_spawn_timer.update(time_passed) # Update and all creeps for creep in self.creeps: creep.update(time_passed) self.draw() pygame.display.flip()