def on_press(self, key): key = key_string(key) global current_key global is_special_key_pressed global recent_input if len(recent_input) <= 100: recent_input.append(key) current_key = key activate_special_key_if_pressed(key) for combination in self.combos.values(): if combo(combination, current_key): release_all_special_keys() combination.execute() for keyword in self.keywords.values(): joined_recent_input = ''.join(recent_input) if keyword.joined_string_list in joined_recent_input: recent_input = [] keyword.execute()
def on_release(self, key): key = key_string(key) deactivate_special_key_if_released(key) if key == 'esc': return False