This is why you don't run random stuff.
Yesterday I was trying to figure ouut some obscure input things in CobraPy such as "detecting the Enter key" and ran into a lovely package in PyPI: Pymput
What does it do? It lets you inject and read input events.
And by input events I mean mouse andkeyboard.
And it does so in your whole session.
And you wouldn't notice if it was doing that.
And it does this in 20 lines of friendly python code. Here, have a keyboard sniffer:
from pynput import keyboard
def on_press(key):
try:
print('alphanumeric key {0} pressed'.format(
key.char))
except AttributeError:
print('special key {0} pressed'.format(
key))
def on_release(key):
print('{0} released'.format(
key))
if key == keyboard.Key.esc:
# Stop listener
return False
# Collect events until released
with keyboard.Listener(
on_press=on_press,
on_release=on_release) as listener:
listener.join()
This is one of the reasons why Wayland (or Mir, I remember Mir!) needs to happen. It's trivial for any desktop app to monitor everything you do. Of course nowadays you also will see software advertising this, as a "feature" where it's used to "monitor employee productivity".
Because remember, often things are only illegal when individuals do them, if you are a company and are charging for it, then Bob's your uncle.