10 examples of 'python keypress' in Python

Every line of 'python keypress' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
17def keypress(key):
18 #keyboard.press(key)
19 #keyboard.release(key)
20 os.system("xdotool key %s" % key)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

585def keypress(key):
586 if key in ('q', 'Q', 'esc'):
587 raise urwid.ExitMainLoop()
320def keypress(event):
321
322 # Strip literal quotes from key symbol
323 keysym = repr(event.keysym)[1:-1]
324
325 # Assume no arrow keys pressed
326 event.widget.axis_x, event.widget.axis_y = 0,0
327
328 # Check all arrow keys
329 if keysym == 'Right':
330 event.widget.axis_x = +1
331 elif keysym == 'Left':
332 event.widget.axis_x = -1
333 if keysym == 'Up':
334 event.widget.axis_y = +1
335 elif keysym == 'Down':
336 event.widget.axis_y = -1
337
338 # Spacebar toggles autopilot
339 elif keysym == 'space':
340 event.widget.autopilot = not event.widget.autopilot
341
342 # If any arrow key was pressed, axes have been set
343 if event.widget.axis_x or event.widget.axis_y:
344
345 # Record arrow-key press time for fake release
346 event.widget.lastpress_sec = time.time()
347
348 # Axis control disables autopilot
349 event.widget.autopilot = False
71def keypress(self, evt):
72 temp = self.text
73 super(Console, self).keypress(evt)
74 if temp == self.text:
75 if evt.key == const.K_RETURN:
76 self.lastscommands.append(self.text)
77 self.current_command = len(self.lastscommands)
78 self.execute_command(self.text)
79 self.text = ""
80 elif evt.key == const.K_UP:
81 if self.current_command > 0:
82 self.current_command -= 1
83 self.text = self.lastscommands[self.current_command]
84 elif evt.key == const.K_DOWN:
85 if self.current_command < len(self.lastscommands) - 1:
86 self.current_command += 1
87 self.text = self.lastscommands[self.current_command]
88 elif self.current_command < len(self.lastscommands):
89 self.text = ""
90 self.current_command += 1
31def key_pressed_handler(self, event):
32 key = event.key()
33
34 if key == QtCore.Qt.Key_Tab:
35 self.handle_tab_key(event)
36 elif key in (
37 QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter, QtCore.Qt.Key_Space):
38 self.handle_complete_key(event)
39 elif key == QtCore.Qt.Key_Escape:
40 self.hide_completion_suggestions()
464def keypress(self, size, key):
465 if key not in ["up", "down"]:
466 return urwid.ListBox.keypress(self, size, key)
467 return key
87def keypress(self, size: Tuple[int, int], key: str) -> None:
88 if key == 'enter':
89 urwid.emit_signal(self, 'done', self, self.get_edit_text())
90 return self._callback(self.edit_text) \
91 if self._callback is not None else None
92
93 super().keypress(size, key)
58@handle('f2')
59def _(event):
60 """
61 Show/hide sidebar.
62 """
63 python_input.show_sidebar = not python_input.show_sidebar
64 if python_input.show_sidebar:
65 event.app.layout.focus(python_input.ptpython_layout.sidebar)
66 else:
67 event.app.layout.focus_last()
302def test_MicroPythonREPLPane_keyPressEvent_CTRL_V_Darwin():
303 """
304 Ensure end key in the REPL is handled correctly.
305 """
306 mock_serial = mock.MagicMock()
307 rp = mu.interface.panes.MicroPythonREPLPane(mock_serial)
308 rp.paste = mock.MagicMock()
309 data = mock.MagicMock()
310 data.key = mock.MagicMock(return_value=Qt.Key_V)
311 data.text = mock.MagicMock(return_value="1b")
312 data.modifiers.return_value = Qt.ControlModifier | Qt.ShiftModifier
313 rp.keyPressEvent(data)
314 rp.paste.assert_called_once_with()
61def keypress_up(self, size):
62 self.keypress(size, '<Up>')

Related snippets