Python Forum
curses key codes not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
curses key codes not working
#1
I am attempting to use curses in python. I am finding that the keycodes are
possibly not correct.

here is some sample code I'm using to test the keys

stdscr.keypad(True)
c = stdscr.getch()
if c == curses.KEY_ENTER:
using this code, str(hex( c )) equals 0xa
and the value of str(hex(curses.KEY_ENTER)) equals 0x157
and the value of str(int(curses.KEY_ENTER)) equal 343

so a test like this is never true

if c==curses.KEY_ENTER:

will not work

I know I can test using another way. I'd prefer to use those constants

I found that tests for curses.KEY_LEFT and curses.KEY_RIGHT do work and the test for curses.KEY_BACKSPACE does not work
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I want to be able to scroll up in curses to see previous text. Caiden 1 716 Jul-28-2023, 01:15 PM
Last Post: deanhystad
  curses issue otalado 2 2,682 Jun-29-2021, 02:07 PM
Last Post: tmz
  How to make curses.border() use A_BOLD atttribute? pjfarley3 0 4,776 Feb-03-2021, 11:22 PM
Last Post: pjfarley3
  Curses script doesn't work wavic 1 4,064 Jan-08-2021, 09:11 PM
Last Post: wavic
  Why aren't all curses panel functions supported in python curses.panel? pjfarley3 2 2,616 Jul-22-2020, 11:08 PM
Last Post: pjfarley3
  curses library autompav96 2 2,844 Mar-02-2019, 02:12 AM
Last Post: woooee
  Pretty table and curses? MuntyScruntfundle 0 2,850 Oct-16-2018, 10:22 AM
Last Post: MuntyScruntfundle
  curses.initscr doesn't work zaphod424 3 9,691 Feb-28-2018, 12:36 PM
Last Post: Gribouillis
  Curses could not find terminal Solstice 13 16,864 Jan-06-2018, 07:56 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020