def press_key_string(self, keystr): """ Send key presses for all characters in a unicode string and keep track of the changes in input_line. """ capitalize = False keystr = keystr.replace("\\n", "\n") if self._vk: # may be None in the last call before exiting for ch in keystr: if ch == "\b": # backspace? keysym = get_keysym_from_name("backspace") self.press_keysym (keysym) self.release_keysym(keysym) elif ch == "\x0e": # set to upper case at sentence begin? capitalize = True elif ch == "\n": # press_unicode("\n") fails in gedit. # -> explicitely send the key symbol instead keysym = get_keysym_from_name("return") self.press_keysym (keysym) self.release_keysym(keysym) else: # any other printable keys self.press_unicode(ch) self.release_unicode(ch) return capitalize
def _send_key_release(self): key_synth = self.keyboard._key_synth ktype = self.key_type if ktype == KeyCommon.CHAR_TYPE: key_synth.release_unicode(self.code) elif ktype == KeyCommon.KEYSYM_TYPE: key_synth.release_keysym(self.code) elif ktype == KeyCommon.KEYPRESS_NAME_TYPE: key_synth.release_keysym(get_keysym_from_name(self.code)) elif ktype == KeyCommon.KEYCODE_TYPE: key_synth.release_keycode(self.code);