tkinter - Python key pressed without Tk -


i use raspberry pi via ssh windows 7 , build robot. if press arrow, move. detect key tkinter module, needs graphic environment. if in ssh terminal, can't run. there module can detect keys , doesn't need window?

i have not tried it, quick search has shown this:
example
github source

which linux implementation of pyhook (windows only)

so use it:

import pyxhook import time  #this function called every time key presssed def kbevent( event ):     #print key info     print event      #if ascii value matches spacebar, terminate while loop     if event.ascii == 32:         global running         running = false  #create hookmanager hookman = pyxhook.hookmanager() #define our callback fire when key pressed down hookman.keydown = kbevent #hook keyboard hookman.hookkeyboard() #start our listener hookman.start()  #create loop keep application running running = true while running:     time.sleep(0.1)  #close listener when done hookman.cancel() 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -