File: keyboard-test.py

package info (click to toggle)
pynput 1.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 596 kB
  • sloc: python: 6,309; makefile: 10; sh: 1
file content (23 lines) | stat: -rw-r--r-- 420 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import sys
sys.path.append(
    os.path.join(os.path.dirname(__file__), '..', 'lib'))

from pynput import keyboard


def on_press(key):
    print('=> %s' % key)
    if key == keyboard.Key.esc:
        return False


def on_release(key):
    print('=< %s' % key)


with keyboard.Listener(
        on_press=on_press,
        on_release=on_release) as listener:
    print('Press esc to exit')
    listener.join()