Search code examples
keyncurses

NCurses and ESC,ALT keys


I have a problem with NCurses... i need to handle all keys like Esc, Alt+F etc. Problem is that the codes are similar... i.e:


Esc - 27


Alt+A - 27 65


As an example there is double code for Alt+[key] combination what similar to Esc key... Any ideas how handle that?


Solution

  • Resolved by:

    1. Use noecho or timeout mode
    2. Check for 27(ALT or ESC) code... if pass:
    3. try to read another code
    4. if another code is ERR then.. you have ESC key in other way you have ALT+another code