1

So I've been playing with Getch recently. So let's say we do something like this...

from msvcrt import getch

while True:
    key = ord(getch())
    if key == 27: #ESC
        print ("Value Read")
        break
    elif key == 13: #Enter
        select()
    elif key == 224: #Special keys (arrows, f keys, ins, del, etc.)
        key = ord(getch())
        if key == 80: #Down arrow
            moveDown()
        elif key == 72: #Up arrow
            moveUp()

What I would like to do is have the Python console read the input such that I don't have to have the Python console as my active window. Does anybody know how to do this as it looks like "getch" just looks for input in the console (this isn't what I was looking for and I'm not sure if this is possible in Python).

Thank you for your time and consideration,

mmacheerpuppy

2

1 Answer 1

0

You may want to use win32api as a wrapper to GetAsyncKeyState

have a look a more detailed answer about this in:

Detecting Key Presses using win32api in Python

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I look forward to having a look at this. Currently in the process of trying to turn my python passion into a career.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.