How to use the pynput.keyboard.Key.ctrl 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_hotkey_tests.py View on Github external
def test_parse_valid(self):
        self.assertSetEqual(
            HotKey.parse('a'),
            {
                kc.from_char('A')})
        self.assertSetEqual(
            HotKey.parse('+a'),
            {
                k.ctrl,
                kc.from_char('A')})
        self.assertSetEqual(
            HotKey.parse('++a'),
            {
                k.ctrl,
                k.alt,
                kc.from_char('A')})
github moses-palmer / pynput / tests / keyboard_listener_tests.py View on Github external
def test_modifier(self):
        """Tests that the modifier keys can be tapped"""
        from pynput.keyboard import Key
        for key in (
                (Key.alt, Key.alt_l, Key.alt_r),
                (Key.ctrl, Key.ctrl_l, Key.ctrl_r),
                (Key.shift, Key.shift_l, Key.shift_r)):
            self.notify('Press <%s>' % key[0].name)
            self.assert_keys(
                'Failed to register event',
                (key, True))
github moses-palmer / pynput / tests / keyboard_controller_tests.py View on Github external
def test_ctrl_pressed(self):
        """Asserts that ctrl_pressed works"""
        for key in (
                pynput.keyboard.Key.ctrl,
                pynput.keyboard.Key.ctrl_l,
                pynput.keyboard.Key.ctrl_r):
            self.controller.press(key)
            self.assertTrue(
                self.controller.ctrl_pressed,
                'ctrl_pressed was not set with %s down' % key.name)
            self.controller.release(key)
            self.assertFalse(
                self.controller.ctrl_pressed,
                'ctrl_pressed was incorrectly set')
github GDGVIT / Lookup-Dictionary / Partial / main.py View on Github external
def StartCopy():
	import sys
	keyboard = Controller()
	with keyboard.pressed(Key.ctrl):
		keyboard.press('c')
		keyboard.release('c')
	
	app=QtGui.QApplication(sys.argv)
	window=DictionBox()
	window.show()
	app.quit()
	app.exec_()
	while True:
		keylistener = KeyListener()
		keylistener.addKeyListener("L_CTRL+q", StartCopy)
		handle = Handler(keylistener)
github GDGVIT / Lookup-Dictionary / main.py View on Github external
def StartCopy():
    import sys
    keyboard = Controller()
    with keyboard.pressed(Key.ctrl):
        keyboard.press('c')
        keyboard.release('c')

    app = QtGui.QApplication(sys.argv)
    window = DictionBox()
    mouse = pymouse.PyMouse()
    x,y=mouse.position()
    if x - 130 >=0:
    	x=x-139

    y=y+20

    window.move(x,y)
    window.show()
    app.quit()
    app.exec_()
github cos301-2019-se / Follow-Me-Drones / server / droneManualControls.py View on Github external
if key.char == 'a':
                # print('Rotating left')
                # self.bebop(moveBy(0, 0, 0, -math.radians(30)))
                self.bebop(PCMD(1, 0, 0, -100, 0, 0))
            
            if key.char == 'd':
                # print('Rotating right')
                # self.bebop(moveBy(0, 0, 0, math.radians(30)))
                self.bebop(PCMD(1, 0, 0, 100, 0, 0))
            
        except AttributeError:
            # print('special key {0} pressed'.format(key))

            # Vertical controls
            # ctrl
            if key == keyboard.Key.ctrl:
                # print('Moving down')
                # self.bebop(moveBy(0, 0, 1, 0)).wait()
                self.bebop(PCMD(1, 0, 0, 0, -50, 50))

            # space
            if key == keyboard.Key.space:
                # print('Moving up')
                # self.bebop(moveBy(0, 0, -1, 0)).wait()
                self.bebop(PCMD(1, 0, 0, 0, 50, 50))
github CopyTranslator / CopyTranslator / CopyTranslator / CopyTranslator.py View on Github external
def simulateCopy(self):
        with self.keyboard.pressed(Key.ctrl):
            self.keyboard.press('c')
            self.keyboard.release('c')
github trns1997 / AUV-Project / scripts / TELEOPERATION.py View on Github external
def on_press(key):
	if key == keyboard.Key.up:
		print("forward")
		pi.set_servo_pulsewidth(SERVO_1, forward+80)
		pi.set_servo_pulsewidth(SERVO_2, forward)

	elif key == keyboard.Key.ctrl:
		print("up")
		pi.set_servo_pulsewidth(SERVO_3, forward)
		pi.set_servo_pulsewidth(SERVO_4, reverse)

	elif key == keyboard.Key.tab:
		print("down")
		pi.set_servo_pulsewidth(SERVO_3, reverse)
		pi.set_servo_pulsewidth(SERVO_4, forward)

	elif key == keyboard.Key.down:
		print("backward")
		pi.set_servo_pulsewidth(SERVO_1, reverse)
		pi.set_servo_pulsewidth(SERVO_2, reverse)
	elif key == keyboard.Key.left:
		print("right")
		pi.set_servo_pulsewidth(SERVO_1, reverse)
github tadejmagajna / TensorMouse / tensormouse / workers.py View on Github external
def keypress_listener(key):
    """ Key press listener """

    from pynput.keyboard import Key
    global mouse_state

    if key == Key.ctrl:
        mouse_state.value = MOUSE_CLICK
    elif key == Key.alt:
        mouse_state.value = MOUSE_DRAG
    elif key == Key.caps_lock:
        mouse_state.value = QUIT
github CopyTranslator / CopyTranslator / copyTranslator / controller.py View on Github external
def simulateCopy(self):
        with self.keyboard.pressed(Key.ctrl):
            self.keyboard.press('c')
            self.keyboard.release('c')