def _event_keypress(self, kev, data): buf = xlib.create_string_buffer(16) keysym = xlib.KeySym() status = xlib.Status() ret = xlib.Xutf8LookupString(self._kbd_replay_xic, kev, buf, len(buf), xlib.byref(keysym), xlib.byref(status)) if ret != xlib.NoSymbol: if 32 <= keysym.value <= 126: # avoid ctrl sequences, just take the character value data.string = chr(keysym.value) else: try: data.string = buf.value.decode('utf-8') except UnicodeDecodeError: pass data.keysym = keysym.value data.status = status.value
def _event_keypress(self, kev, data): buf = xlib.create_string_buffer(16) keysym = xlib.KeySym() status = xlib.Status() ret = xlib.Xutf8LookupString(self.replay_xic, kev, buf, len(buf), xlib.byref(keysym), xlib.byref(status)) if ret != xlib.NoSymbol: if 32 <= keysym.value <= 126: # avoid ctrl sequences, just take the character value data.string = chr(keysym.value) else: try: data.string = buf.value.decode('utf-8') except UnicodeDecodeError: pass data.keysym = keysym.value data.status = status.value