10 examples of 'detect key press python' in Python

Every line of 'detect key press python' 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
81def pressTest(self, key):
82 print( "-> Pressing " + key.upper() )
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

17def keypress(key):
18 #keyboard.press(key)
19 #keyboard.release(key)
20 os.system("xdotool key %s" % key)
191def key_input(self, window, key, scancode, codepoint, modifier):
192 if key == 27:
193 self.manager.go_back()
194 return True # back button now does nothing on Android
195 return False
63@motion
64def keypress_k(self, count):
65 row, column = self.editor.active_window.cursor
66 return row - count, column
95@handle(Keys.ControlP)
96def _(event):
97 " Previous line. "
98 event.current_buffer.auto_up(count=event.arg)
28def key_press(self, obj, event):
29 key = self.fetch_pressed()
30 self.key_pressed(key, **self.current_modifiers())
74def onKeyEventScancode(self, code, isPressed, isExtended):
75 """ HoneyPot """
164def pressAndHold(*args):
165 '''
166 press and hold. Do NOT release.
167 accepts as many arguments as you want.
168 e.g. pressAndHold('left_arrow', 'a','b').
169 '''
170 for i in args:
171 win32api.keybd_event(VK_CODE[i], 0, 0, 0)
172 time.sleep(.05)
72def processKeyPress(press):
73 keypresses.append((press.key, press.unicode))
468def key_press_handler(self, view, event):
469 buf = view.get_buffer()
470 if self.__not_available or buf.get_has_selection(): return
471 # Get tabs/indent configuration
472 if view.get_insert_spaces_instead_of_tabs():
473 indent_width = ' ' * view.get_tab_width()
474 else:
475 indent_width = '\t'
476 keyval = event.keyval
477 self.__update_line_no(buf)
478 if keyval == 65293:
479 # Check next line indentation for current line
480 line = self.__get_current_line(view, buf)
481 if self.re_indent_next and self.re_indent_next.match(line):
482 old_indent = line[:len(line) - len(line.lstrip())]
483 indent = '\n'+ old_indent + indent_width
484 buf.insert_interactive_at_cursor(indent, True)
485 return True
486 elif keyval == 65288:
487 line = self.__get_current_line(view, buf)
488 if line.strip() == '' and line != '':
489 length = len(indent_width)
490 nb_to_delete = len(line) % length or length
491 cursor_position = buf.get_property('cursor-position')
492 iter_cursor = buf.get_iter_at_offset(cursor_position)
493 iter_before = buf.get_iter_at_offset(cursor_position - nb_to_delete)
494 buf.delete_interactive(iter_before, iter_cursor, True)
495 return True
496 elif self.unindent_keystrokes:
497 if keyval in [ord(k) for k in self.unindent_keystrokes]:
498 line = self.__get_current_line(view, buf)
499 if self.__line_unindented != self.__line_no:
500 line_eval = line+chr(event.keyval)
501 if self.re_unindent_curr and self.re_unindent_curr.match(line_eval):
502 cursor_iter = buf.get_iter_at_mark(buf.get_insert())
503 line_start_iter = cursor_iter.copy()
504 view.backward_display_line_start(line_start_iter)
505 iter_end_del = buf.get_iter_at_offset(line_start_iter.get_offset() + len(indent_width))
506 text = buf.get_text(line_start_iter, iter_end_del)
507 if text.strip() == '':
508 buf.delete_interactive(line_start_iter, iter_end_del, True)
509 self.__line_unindented = self.__line_no
510 return False
511 return False

Related snippets