summaryrefslogtreecommitdiff
path: root/README
blob: 1b6e64783974ee32611823b31b875238bf2a6329 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Keyboard-python is a simple module for parsing keyboard input.
It is useful because it can tell you keypresses without the need
for the Enter key to be pressed and can parse the following:

F-keys
Home
End
PageUp
PageDown
Tab
Insert
Delete
Escape
Alt modified keys
Ctrl modified keys

Example:

    import sys
    import keyboardpython as kbpy

    alt_A = kbpy.Key('A',key.ALT)
    alt_a = kbpy.Key('a',key.ALT)

    fd = sys.stdin.fileno()
    kbpy.init(fd)
    k = getkey(fd)
    kbpy.close(fd)

    if k == alt_A:
        print "You pressed Alt+A!"
    elif k == alt_a:
        print "You pressed Alt+a!"
    elif k.contains_key(key.ALT):
        print "You pressed Alt but not A"
    elif k.string in 'aA':
        print "You pressed a but not Alt"
    else:
        print "You didn't press Alt or A :("