keyboard fails on a Mac and I would like to use pynput but fail to execute successfully.
from pynput import keyboard
import time
def on_press(key, ts, gt_forward, rb, extent, aoi, aoibuffer, jparams):
if key == keyboard.Key.enter:
print("\nYou pressed Enter... we continue with osm_LoD1_3DCityModel.")
...lots of code that saves something.
def on_release(key):
if key == keyboard.Key.esc:
# Stop listener
return False
def main():
start = time.time()
...code here...
print('')
print("Have a look at the matplotlib render that might highlight errors (red) in the 2D vectors.\n\nIf there are no challenges press 'Enter' to continue; else press 'Esc' to exit: ")
with keyboard.Listener(
on_press=lambda key: on_press(key, ts, gt_forward, rb, extent, aoi, aoibuffer, jparams),
on_release= on_release) as listener:
listener.join()
end = time.time()
print('runtime:', str(timedelta(seconds=(end - start))))
if __name__ == "__main__":
main()
on_press executes successfully and what I need gets written to file but the script does not move on to:
end = time.time()
print('runtime:', str(timedelta(seconds=(end - start))))
I am not sure of the proper syntax.
Also will the revised script, with pynput, execute successfully on a Windows machine?