How to use the pynput.keyboard.Key function in pynput

To help you get started, we’ve selected a few pynput examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moses-palmer / pynput / tests / keyboard_controller_tests.py View on Github external
def test_controller_events(self):
        """Tests that events sent by a controller are received correctly"""
        with self.assert_event(
                'Failed to send press',
                on_press=lambda k: getattr(k, 'char', None) == u'a'):
            self.controller.press(u'a')
        with self.assert_event(
                'Failed to send release',
                on_release=lambda k: getattr(k, 'char', None) == u'a'):
            self.controller.release(u'a')

        self.controller.press(pynput.keyboard.Key.enter)
        self.controller.release(pynput.keyboard.Key.enter)
        input()
github CopyTranslator / CopyTranslator / windows_pack / CopyTranslator.py View on Github external
def simulateCopy(self):
        with self.keyboard.pressed(Key.ctrl):
            self.keyboard.press('c')
            self.keyboard.release('c')
github shirokunet / RCVehiclePy / demo / demo_keyboard_controller.py View on Github external
def _on_release(self, key):
        if key == keyboard.Key.up or key == keyboard.Key.down:
            self.throttle.value = 0.0
        elif key == keyboard.Key.left or key == keyboard.Key.right:
            self.steering.value = 0.0
github anuragpeshne / vKeyboard / host.py View on Github external
def on_release(key):
            if key == Key.esc:
                # Stop listener
                return False
            elif key == Key.caps_lock:
                self.send = not self.send
            if self.send and key != Key.caps_lock:
                self.sendKey(key, Host.KEY_RELEASE)
github shanefarris / RTFM / Framework / Screen.py View on Github external
def on_press(self, key):
        #keyboard.type('test')
        if key == keyboard.Key.up:
            keyboard.type('UP\n')
            self._cmdHistoryIndex -= 1
        elif key == keyboard.Key.down:
            keyboard.type('DOWN\n')
            self._cmdHistoryIndex += 1

        if self._cmdHistoryIndex < 0:
            self._cmdHistoryIndex == 0;
        elif self._cmdHistoryIndex > (len(self._cmdHistory) - 1):
            self._cmdHistoryIndex = len(self._cmdHistory) - 1

        return