Giter VIP home page Giter VIP logo

Comments (2)

bschley avatar bschley commented on July 20, 2024

How I exacly use the win32_event_filter?

with keyboard.Listener(on_press=on_press, on_release=None, kwargs=<can`t get it to work>) as listener:
...

from pynput.

BA-24 avatar BA-24 commented on July 20, 2024

I have stumbled upon this issue myself, however, I don't think using the win32_event_filter is a real solution since it undermines a significant portion of the code written for it to be cross-compatible. The way this problem manifests on my PC is that all keyboard inputs are significantly delayed after switching from using the listener with the suppressed flag and then going back to using it without the suppressed flag (no matter any background tasks). I am fully willing to arrange some sort of setup using something like TeamViewer if you want to play around with the issue on a machine where you can easily reproduce it.

Here is the code I'm using to produce the bug

from pynput.keyboard import Key, Listener

keyThread = None

def on_press(key):
    if key == Key.esc: keyThread.stop() # stop code
    
    elif key == Key.pause: # restart with suppress
        keyThread.stop()
        startListener(suppress=True)
        
    elif key == Key.backspace: # restart without suppress
        keyThread.stop()
        startListener()
        
    print(key) # print key


def startListener(suppress=False):
    global keyThread

    with Listener(on_press=on_press, suppress=suppress) as keyThread:
        keyThread.join()
        
startListener()

To reproduce it, you can run the code, open some sort of text editor and press the pause key followed by the backspace key and then try writing some text.

from pynput.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.