Curses::UI Escape key bindings are slow; here’s why.

I am throwing together a quick Curses (console / terminal) based UI for a database here, prior to putting (or hiring someone to put!) a Web front-end on it. In keeping with my experience with elinks, I wanted the menubar activation key to be Escape. However, it was running slower than molasses in February — it seemed to take a FULL SECOND before the Esc key would register and focus / unfocus the menubar.

Well, poking around a bit gave me the answer. From man ncurses(3):

ESCDELAY   Specifies the total time, in milliseconds, for which ncurses will   await a character sequence, e.g., a function key.  The default   value, 1000 milliseconds, is enough for most uses.  However, it is   made a variable to accommodate unusual applications."  

Duh. It was taking exactly a full second.

2 Responses to “Curses::UI Escape key bindings are slow; here’s why.”

  1. Nelson says:

    Thanks, I really was trying to figure why only ESC had this delay. Now I set ESCDELAY to 1 ms.

  2. rlucas says:

    Yes — but be advised that on slow links, things like VT100 escape sequences might be broken with so small a delay.

Leave a Reply