Re: Esc key

Search this archive.

From: Sergio Masci (sergio@titan.demon.co.uk)
Date: Fri 10 Mar 2000 - 20:16:03 IST


> 
> 
> Hi again,
> 
> Ok, I'm sure I could figure this one out for myself if I put some time
> into it, but I'm also thinking someone (like Russell) has maybe already
> solved it.
> 
> So, in a public display of the languor and apathy that I'm feeling today, 
> I'll post my question here.  ;-P
> 
> When using vga_getch() and vga_getkey(), how do you avoid a value of "27"
> applying to more than just the "Esc" key? I know the directional arrows
> are "escaped", and so pressing the up arrow sends (at first) the same
> signal as the Esc key. This is the same problem as you get with ncurses.
> 
> So, what's the answer? Can this be done without raw keyboard mode?
> 
> 
> Thanks,
> 
> -Mr. Brain Dead

Use vga_getkey() to read the keyboard, if you see an ESC read it again
immediately (without waiting). If you get 0 then no other key was
pressed and you have an ESC key press, if you get anything else then
treat it as an escape sequence.

I forget if you need to explicitly tell SVGALIB to use vga_getkey() as
non-blocking. If it does, then you'll need to set it to non-blocking.

I don't know about this ncurses problem, but this method also works with
normal terminals connected to a unix box, you just need to be sure to
set the line disaplin for the terminal to non-blocking, set stdin to
unbuffered using setbuf or setvbuf and away you go.

Regards
Sergio


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST