0

I need to accept Alt+F-key's in my application. The application needs to run on Windows and Linux. I'm using the following code to test what getch receives when I press Alt+F1:

import curses

def main(stdscr):
    while True:
        ch = stdscr.getch()
        print(ch)

if __name__ == "__main__":
    curses.wrapper(main)

On Windows (using windows-curses) I get 277. On Linux via Putty I get 27 265. On WSL in Windows Terminal I get 27 91 49 59 51 80. Ignoring the Windows value, I assume the issue in Linux is how the different terminals encode the key press. But is one of these "correct"? Is curses supposed to handle the cross-platform differences, or am I supposed to do that myself?

FrederikVds
  • 551
  • 4
  • 11

0 Answers0