How to use the pynput.keyboard.Key.up 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 RedFantom / python-rgbkeyboards / rgbkeyboards / keygroups.py View on Github external
'pageup', 'delete', 'end', 'pagedown', 'P1', 'P2', 'P3', 'P4']

pynput_rgb_keys = {
    Key.shift: "shift_l",
    Key.shift_l: "shift_l",
    Key.shift_r: "shift_r",
    Key.alt: "alt_l",
    Key.alt_gr: "alt_r",
    Key.alt_r: "alt_r",
    Key.alt_l: "alt_l",
    Key.backspace: "backspace",
    Key.pause: "pause",
    Key.esc: "esc",
    Key.print_screen: "printscreen",
    Key.scroll_lock: "scrollock",
    Key.up: "up",
    Key.down: "down",
    Key.left: "left",
    Key.right: "right",
    Key.insert: "insert",
    Key.home: "home",
    Key.page_up: "pageup",
    Key.delete: "delete",
    Key.end: "end",
    Key.page_down: "pagedown",
    Key.enter: "enter",
    Key.f1: "F1",
    Key.f2: "F2",
    Key.f3: "F3",
    Key.f4: "F4",
    Key.f5: "F5",
    Key.f6: "F6",
github plstcharles / thelper / thelper / gui / annotators.py View on Github external
def handle_keys(self):
        """Fetches the latest keyboard press and updates the annotator state accordingly."""
        assert thelper.utils.check_installed("pynput.keyboard"), \
            "could not import optional 3rd-party dependency 'pynput'; make sure you install it first!"
        import pynput.keyboard
        cls = ImageSegmentAnnotator
        nb_labels = len(self.labels)
        if cls.CURRENT_KEY != -1:
            if cls.CURRENT_KEY == pynput.keyboard.Key.down or cls.CURRENT_KEY == pynput.keyboard.KeyCode(char='s'):
                cv.imwrite(self.get_mask_path(self.curr_sample_idx), self.mask)
                self.curr_sample_idx = min(self.curr_sample_idx + 1, self.sample_count - 1)
                logger.debug("loading image+mask #%d... (max=%d)" % (self.curr_sample_idx, self.sample_count - 1))
                if self.curr_sample_idx == self.sample_count - 1:
                    logger.debug("(reached last)")
                self.image, self.mask = self.load(self.curr_sample_idx)
            elif cls.CURRENT_KEY == pynput.keyboard.Key.up or cls.CURRENT_KEY == pynput.keyboard.KeyCode(char='w'):
                cv.imwrite(self.get_mask_path(self.curr_sample_idx), self.mask)
                self.curr_sample_idx = max(self.curr_sample_idx - 1, 0)
                logger.debug("loading image+mask #%d... (max=%d)" % (self.curr_sample_idx, self.sample_count - 1))
                self.image, self.mask = self.load(self.curr_sample_idx)
            elif cls.CURRENT_KEY == pynput.keyboard.Key.right:
                self.curr_label_idx = min(self.curr_label_idx + 1, nb_labels - 1)
                curr_label = self.labels[self.curr_label_idx]
                logger.debug("swapping to label #%s : '%s'" % (curr_label["id"], curr_label["name"]))
                cls.GUI_DIRTY = True
            elif cls.CURRENT_KEY == pynput.keyboard.Key.left:
                self.curr_label_idx = max(self.curr_label_idx - 1, 0)
                curr_label = self.labels[self.curr_label_idx]
                logger.debug("swapping to label #%s : '%s'" % (curr_label["id"], curr_label["name"]))
                cls.GUI_DIRTY = True
            elif cls.CURRENT_KEY == pynput.keyboard.Key.page_up:
                self.mask_opacity = max(self.mask_opacity - 0.1, 0.0)
github asingh33 / SupervisedChromeTrex / main.py View on Github external
def on_press(key):
    global isEscape, saveImg, sc, counter1, counter2
    
    # Pressing 'UP arrow key' will initiate saving provided capture region images
    if key == keyboard.Key.up:
        saveImg = True
        #sc.capture()
        img = sc.getmssimage()
        counter1 = sc.saveROIImg("jump", img, counter1)
    
    # Pressing 'Right arrow key' will initiate saving provided capture region images
    if key == keyboard.Key.right:
        saveImg = True
        #sc.capture()
        img = sc.getmssimage()
        counter2 = sc.saveROIImg("nojump", img, counter2)
github shirokunet / RCVehiclePy / demo / demo_keyboard_controller.py View on Github external
def _on_press(self, key):
        if key == keyboard.Key.esc:
            self.is_run.value = False
        elif key == keyboard.Key.up:
            self.throttle.value = 1.0
        elif key == keyboard.Key.down:
            self.throttle.value = -1.0
        elif key == keyboard.Key.left:
            self.steering.value = -1.0
        elif key == keyboard.Key.right:
            self.steering.value = 1.0
github shirokunet / RCVehiclePy / pc_main.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 GokulNC / Setting-Up-CARLA-Reinforcement-Learning / human_play.py View on Github external
def on_release(key):
		global action
		if key == keyboard.Key.up or key == keyboard.Key.down: action[0] = 0.0
		elif key == keyboard.Key.left or key == keyboard.Key.right:
			action[1] = 0.0
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")
github musabkilic / MicroBike / controller.py View on Github external
#Start the Program if a Button is Pressed
	if microbit.button_a.was_pressed() or microbit.button_b.was_pressed():
		break
	time.sleep(0.5)

#Start the Loop
while 1:
	#Get Accelerometer Values
	accelerometer_values = microbit.accelerometer.get_values()
	x,y,z = accelerometer_values

	#Calculate Avarege Motion in X,Y,Z Directions
	motion = sum(map(lambda x:abs(accelerometer_values[x]-previous_values[x]),range(3)))/3

	#Change Direction
	changeKeyState(Key.up, y>400)
	changeKeyState(Key.right, x>60)
	changeKeyState(Key.left, x<-60)
	changeKeyState(Key.shift, motion>500)

	#Set Direction to Show
	direction = ""
	if y>400:
		direction += "N"
	if x>60:
		direction += "E"
	elif x<-60:
		direction += "W"

	#Show the Direction
	microbit.display.show(images[direction])
	#Set Current Accelerometer Values to Previous
github andreasgrv / johnny / train.py View on Github external
def on_press(key):
            INCREMENT = 0.1
            if key == pynput.keyboard.Key.esc:
                built_conf.model.visualise = not built_conf.model.visualise
            elif key == pynput.keyboard.Key.up:
                built_conf.model.sleep_time += INCREMENT
            elif key == pynput.keyboard.Key.down:
                if built_conf.model.sleep_time >= INCREMENT:
                    built_conf.model.sleep_time -= INCREMENT