Giter VIP home page Giter VIP logo

Comments (4)

moses-palmer avatar moses-palmer commented on July 20, 2024

Sorry for the very late reply.

If I modify your example thus:

from pynput import keyboard                   
from time import sleep 


def on_press(key):     
    if key == keyboard.Key.esc:               
        lis.stop()     
    else:              
        try:           
            print("key.char", ord(key.char))  
            if(ord(key.char) == 3):           
                print("Ctrl+C Pressed!!!")    
        except:        
            print("key.name", key.name)       


lis = keyboard.Listener(on_press=on_press)    
print("start #1")      
lis.start()            
sleep(100)

...run it and then double click on a file, nothing extraordinary happens. On what platform does this occur?

If you want to detect 'c', by the way, you may want to compare key.char directly against 'c' (ord('c') == 99).

from pynput.

masoudr avatar masoudr commented on July 20, 2024

@moses-palmer I'm using windows, I need to detect Ctrl+C. I think when I double click ord(key.char) gets equal to 3. I don't know why this happening.

from pynput.

moses-palmer avatar moses-palmer commented on July 20, 2024

I'm closing this issue, as I cannot reproduce it. Does the code sample I posted above cause the issue for you?

from pynput.

masoudr avatar masoudr commented on July 20, 2024

@moses-palmer It seems that the problem was related to a windows issue, not the module itself. I haven't faced this issue for a long time. Thanks by the way.

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.