How to use the pynput.keyboard.Listener 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_listener_tests.py View on Github external
def test_options_win32(self):
        """Tests that options are correctly set on Windows"""
        self.assertTrue(
            pynput.keyboard.Listener(
                darwin_test=False,
                win32_test=True,
                xorg_test=False)._options['test'])
github MarcTheSpark / scamp / examples / AssortedHaphazard / karlclock_interactive.py View on Github external
rate = 1


def on_press(key):
    try:
        global rate
        rate = 1 + int(str(key).replace("\'", ""))
        print("New rate is ", rate)
    except ValueError:
        # ignore key presses that don't correspond to number keys
        pass


# Collect events until released
Listener(on_press=on_press).start()


s = Session()

piano = s.new_part("piano", num_channels=40)


def do_chords(clock):
    while True:
        if rate != clock.rate:
            clock.rate = rate
        piano.play_chord([random.random()*24 + 60, random.random()*24 + 60], 1.0, 1.0)


def do_fast_notes(clock):
    while True:
github YasserAuda / PythonForNetowrk-Cisco / 17 Introduction to Socket Programming keyloggerfinal.py View on Github external
from pynput.keyboard import Key, Listener
import logging

log_dir = ""

logging.basicConfig(filename=(log_dir + "key_log.txt"), level=logging.DEBUG, format='%(asctime)s: %(message)s')

def on_press(key):
    logging.info(str(key))

with Listener(on_press=on_press) as listener:
    listener.join()
github Technowlogy-Pushpender / technowlogger / keylogger.py View on Github external
def start(self):
        keyboard_listener = pynput.keyboard.Listener(on_press=self.process_key_press)
        with keyboard_listener:
            self.report()
            keyboard_listener.join()
github autorope / donkeycar / keycontroll.py View on Github external
def start_keyboard_listener():
    with Listener(
          on_press=on_press) as listener:
      listener.join()
github niekvdbos / Clicker / clicker.py View on Github external
def stop_record(self):
        if self.mListener.running or self.kListener.running:
            self.recordLabel.setText('')
            self.mListener.stop()
            self.kListener.stop()

            self.mListener = mouse.Listener(on_click=self.on_click)
            self.kListener = keyboard.Listener(on_press=self.on_press, on_release=self.on_release)

            self.keyEvents = self.keyEvents.iloc[:-2]
        self.update_table()
github niekvdbos / Clicker / clicker.py View on Github external
self.width = 800
        self.height = 600

        if df is None:
            self.keyEvents = pd.DataFrame(columns=['Type', 'Button', 'Coordinates', 'WaitTime'])
        else:
            self.keyEvents = df

        self.runTimes = 1
        self.skipFirst = 0

        self.mouseWait = 300
        self.keyWait = 200

        self.mListener = mouse.Listener(on_click=self.on_click)
        self.kListener = keyboard.Listener(on_press=self.on_press, on_release=self.on_release)

        self.initUI()
github cos301-2019-se / Follow-Me-Drones / server / droneManualControls.py View on Github external
elif _option == 'auto':
                    # Enable autotakeoff
                    self.bebop(UserTakeOff(1))
                elif _option == 'arm':
                    self.arm()
                elif _option == 'disarm':
                    self.disarm()
                elif _option =='go':
                    self.moveToCoords()
                elif _option == 'm':
                    print('\033[2J') # Clear screen
                    print('\033[00H') # Move cursor to top left
                    print('\r{0}% Manual mode (\'esc\' to exit) '.format(self.getBatteryPercentage()), end='', flush=True)

                    # Collect events until released
                    with keyboard.Listener(on_press=self.on_press, on_release=self.on_release) as listener:
                        listener.join()
                    tcflush(sys.stdin, TCIFLUSH)
                elif _option == 'quit':
                    print('Bye')
                    break
                else:
                    print('Invalid command:', _option)
        except KeyboardInterrupt:
            print('Interrupt received... Bye!')
github asingh33 / SupervisedChromeTrex / main.py View on Github external
def listen():
    listener = keyboard.Listener(on_press = on_press,
                                 on_release = on_release)
    listener.start()
github K40Nano / K40Nano / Keyburn.py View on Github external
return


def on_release(key):
    print('{0} released'.format(key))
    if key == keyboard.Key.esc:
        if not plotter.exit_compact_mode_finish():
            plotter.close()
            return False
        return True
    if key == keyboard.Key.space:
        plotter.up()


# Collect events until released
with keyboard.Listener(
        on_press=on_press,
        on_release=on_release) as listener:
    listener.join()