def _event_key(self, msg, wParam, lParam): repeat = False if lParam & (1 << 30): if msg not in (WM_KEYUP, WM_SYSKEYUP): repeat = True ev = 'on_key_release' else: ev = 'on_key_press' symbol = keymap.get(wParam, None) if symbol is None: ch = _user32.MapVirtualKeyW(wParam, MAPVK_VK_TO_CHAR) symbol = chmap.get(ch) if symbol is None: symbol = key.user_key(wParam) elif symbol == key.LCTRL and lParam & (1 << 24): symbol = key.RCTRL elif symbol == key.LALT and lParam & (1 << 24): symbol = key.RALT elif symbol == key.LSHIFT: pass # TODO: some magic with getstate to find out if it's the # right or left shift key. modifiers = self._get_modifiers(lParam) if not repeat: self.dispatch_event(ev, symbol, modifiers) ctrl = modifiers & key.MOD_CTRL != 0 if (symbol, ctrl) in _motion_map and msg not in (WM_KEYUP, WM_SYSKEYUP): motion = _motion_map[symbol, ctrl] if modifiers & key.MOD_SHIFT: self.dispatch_event('on_text_motion_select', motion) else: self.dispatch_event('on_text_motion', motion) # Send on to DefWindowProc if not exclusive. if self._exclusive_keyboard: return 0 else: return None
def _event_key(self, msg, wParam, lParam): repeat = False if lParam & (1 << 30): if msg not in (WM_KEYUP, WM_SYSKEYUP): repeat = True ev = 'on_key_release' else: ev = 'on_key_press' symbol = keymap.get(wParam, None) if symbol is None: ch = _user32.MapVirtualKeyW(wParam, MAPVK_VK_TO_CHAR) symbol = chmap.get(ch) if symbol is None: symbol = key.user_key(wParam) elif symbol == key.LCTRL and lParam & (1 << 24): symbol = key.RCTRL elif symbol == key.LALT and lParam & (1 << 24): symbol = key.RALT if wParam == VK_SHIFT: return # Let raw input handle this instead. modifiers = self._get_modifiers(lParam) if not repeat: self.dispatch_event(ev, symbol, modifiers) ctrl = modifiers & key.MOD_CTRL != 0 if (symbol, ctrl) in _motion_map and msg not in (WM_KEYUP, WM_SYSKEYUP): motion = _motion_map[symbol, ctrl] if modifiers & key.MOD_SHIFT: self.dispatch_event('on_text_motion_select', motion) else: self.dispatch_event('on_text_motion', motion) # Send on to DefWindowProc if not exclusive. if self._keyboard_exclusive: return 0 else: return None