Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

track keyboard press pynput

1   from pynput import keyboard
2
3   def on_press(key):
4        try:
5           print('Key {0} pressed'.format(key.char))
6           #Add your code to drive motor
7       except AttributeError:
8           print('Key {0} pressed'.format(key))
9           #Add Code
10  def on_release(key):
11      print('{0} released'.format(key))
12      #Add your code to stop motor
13      if key == keyboard.Key.esc:
14          # Stop listener
15          # Stop the Robot Code
16          return False
17      if key == keyboard.Key.Qkey:
18          print ("fviokbhvxfb")
19
20  # Collect events until released
21  with keyboard.Listener(
22          on_press=on_press,
23          on_release=on_release) as listener:
24      listener.join()
Comment

PREVIOUS NEXT
Code Example
Python :: how to split a string every 2 characters python 
Python :: make all subplots same height 
Python :: scipy kullbach leibler divergence 
Python :: NumPy bitwise_or Code When inputs are numbers 
Python :: NumPy left_shift Code When inputs and bit shift are numbers 
Python :: django disable foreign key checks temporary 
Python :: django view - apiview decorator (retrieve, update or delete - GET, PUT, DELETE) 
Python :: python code to scan paper table to excel 
Python :: # convert dictionary keys to a list 
Python :: python mysqldb sockets 
Python :: penggunaan len di python 
Python :: Remove Brackets from List Using String Slicing method 
Python :: django hash password Argon 
Python :: python forward declaration 
Python :: fiusion python lists 
Python :: vscode show when variable is protected or private python 
Python :: python flask many to many relation db 
Python :: how to access specific index of matrix in python 
Python :: Trying to use image in Flask website only shows broken img icon 
Python :: dict python inpmenttion 
Python :: EDA describe missing and zero values 
Python :: flask-sqlalchemy inserting a dictionary to a database 
Python :: localizar la fila y columna de un dato pandas 
Python :: python data statics 
Python :: importing cosine from scipy 
Python :: dic to dic arrays must all be same length 
Python :: substituir valor simbólico por valor real em uma equação Python 
Python :: ticklabels are not centered heatmap 
Python :: what does // mean in python 
Python :: python how to compress pytorch model 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =