1

I am currently making a python project in curses, I want to know how to use the control and shift keys using stdscr.getch(), the other keys work, except for a few keys including ctrl and shift.

The code for the files look like this

# script_1.py

import curses

stdscr = curses.initscr()
curses.noecho()
curses.curs_set(False)
curses.start_color()
stdscr.keypad(True)
curses.mousemask(True)


# script_2.py

from script_1 import *

cmd = stdscr.getch()

if cmd == curses.KEY_CONTROL_L:
    print("You pressed Left Control")   # This code won't work

elif cmd == curses.KEY_SHIFT_L:
    print("You pressed Left Shift")     # This code won't work

7
  • There is no such key in curses Commented Jan 28, 2022 at 4:10
  • @ShadowGunn I checked and those keys exist. Commented Jan 28, 2022 at 4:16
  • Okay I could not find them Commented Jan 28, 2022 at 4:17
  • 1
    Have you tried using getkey() instead of .getch()? docs.python.org/3/library/curses.html#curses.window.getkey Commented Jan 28, 2022 at 4:21
  • I tried it. It doesn't work Commented Jan 28, 2022 at 4:30

0

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.