Last active
April 8, 2021 20:07
-
-
Save discretegames/fcd45b6db23ffd54cd8edb9c0d04ce19 to your computer and use it in GitHub Desktop.
Typing Practice
This file contains hidden or 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
# Simple typing practice program where you can choose the keys to focus on. Set FOCUS on line 17. | |
import string | |
import random | |
import keyboard | |
numbers = string.digits | |
number_symbols = ')!@#$%^&*(' | |
lowercase = string.ascii_lowercase | |
uppercase = string.ascii_uppercase | |
unshifted_symbols = r"`-=[]\;',./" | |
shifted_symbols = '~_+{}|:"<>?' | |
brackets = '[]{}()<>' | |
whitespace = '\t \n' | |
# Set what characters to focus on here, e.g. numbers + number_symbols, or say 'all'. | |
FOCUS = 'all' | |
normal = string.ascii_lowercase + numbers + unshifted_symbols | |
shifted = string.ascii_uppercase + number_symbols + shifted_symbols | |
keys = {key: key for key in normal} | |
for i, key in enumerate(shifted): | |
keys[key] = keyboard.get_hotkey_name(['shift', normal[i]]) | |
keys['<'] = keyboard.get_hotkey_name(['shift', '<']) # The 'shift+,' fails for some reason. | |
keys['[space]'] = ' ' | |
keys['[tab]'] = '\t' | |
keys['[enter]'] = '\n' | |
if not FOCUS or FOCUS.lower() == 'all': | |
choices = list(keys.items()) | |
else: | |
choices = [] | |
for key in set(FOCUS): | |
if key == ' ': | |
key = '[space]' | |
elif key == '\t': | |
key = '[tab]' | |
elif key == '\n': | |
key = '[enter]' | |
choices.append((key, keys[key])) | |
print('Started Typing Practice') | |
while True: | |
display, key = random.choice(choices) | |
print(display) | |
keyboard.wait(key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment