moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.79k stars 248 forks source link

Any use of Enter key dumps keys to stdout after exit #371

Closed jimburnsphd closed 3 years ago

jimburnsphd commented 3 years ago

Simplest key listener still dumps all keys pressed to stdout after exit.

from pynput import keyboard, mouse STOP_KEY = keyboard.Key.esc def evt_kybrd_OnPress(key):

print(key)

if(key == STOP_KEY):
    return False

with keyboard.Listener(on_press=evt_kybrd_OnPress) as kL: kL.join() print('Done')

moses-palmer commented 3 years ago

Thank you for your report.

pynput does not inhibit the key events from reaching other parts of your system, so having a key listener active does not affect the keys sent to stdout upon application termination.

If you want to prevent the keys from being printed, and possibly be interpreted by your shell, you may want to drain stdout before exiting.