Skip to content

Commit

Permalink
Make get_typed_strings listen for 'delete' on OSX (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
boppreh committed Mar 30, 2018
1 parent 2544c0f commit a4d831b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion keyboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,8 @@ def get_typed_strings(events, allow_backspace=True):
get_type_strings(record()) #-> ['This is what', 'I recorded', '']
"""
backspace_name = 'delete' if _platform.system() == 'Darwin' else 'backspace'

shift_pressed = False
capslock_pressed = False
string = ''
Expand All @@ -987,7 +989,7 @@ def get_typed_strings(events, allow_backspace=True):
shift_pressed = event.event_type == 'down'
elif event.name == 'caps lock' and event.event_type == 'down':
capslock_pressed = not capslock_pressed
elif allow_backspace and event.name == 'backspace' and event.event_type == 'down':
elif allow_backspace and event.name == backspace_name and event.event_type == 'down':
string = string[:-1]
elif event.event_type == 'down':
if len(name) == 1:
Expand Down

0 comments on commit a4d831b

Please sign in to comment.