from pynput import keyboard

def on_press(key):
    try:
        print('{0}'.format(key.char),end='')
    except AttributeError:
        if key == keyboard.Key.enter:
            print("\r\n")
        #print('special key {0} pressed'.format(key))

def on_release(key):
    return
    print('{0} released'.format(key))
    if key == keyboard.Key.esc:
        # Stop listener
        return False

def on_click(x, y, button, pressed):
    print('{0} {1} at {2}'.format('Pressed' if pressed else 'Released', button, (x, y)))
    if not pressed:
        # Stop listener
        return False

def on_scroll(x, y, dx, dy):
    print('Scrolled {0} at {1}'.format((dx, dy), (x, y)))

def capture_pynput():
    # Collect events until released
    keyboard_listener = keyboard.Listener(on_press=on_press, on_release=on_release)


    keyboard_listener.start()


    keyboard_listener.join()

if __name__ == "__main__":
    capture_pynput()