Skip to content

Instantly share code, notes, and snippets.

melkael

Block or report user

Report or block melkael

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View map.py
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]",
}
View loop.py
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)
View devices.py
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):
View pyxhook.py
import pyxhook
def OnKeyPress(event):
print (event.Key)
hm = pyxhook.HookManager()
hm.KeyDown = OnKeyPress
You can’t perform that action at this time.