[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: alt key
From: |
Christ, Bryan |
Subject: |
Re: alt key |
Date: |
Thu, 07 Dec 2006 11:10:27 -0600 |
Someone may have to chime in and correct me on this, but basically,
there are 3 addtl scan codes returned after esc because it is the
greatest number of multi-key combinations which can be returned...
(examples: ctrl + alt + e, alt + shift + f, etc.).
Notice you can't do 4-key combinations (example: ctrl+shift+alt+e).
I chose to stuff the addtl. scancodes into a 32-bit value when I
encounter an escape sequence (hence the 8-bit and 16-bit shifts). This
allows me to define my own custom keycodes (may suffer portability
though). For example:
#define KEY_SHIFT_LEFT (79 | 50<<8 | 68<<16)
keystroke=get_keystroke();
if(keystroke==KEY_SHIFT_LEFT) printw("you pressed shift+left\n\r");
On Thu, 2006-12-07 at 11:54 -0500, Bob Rossi wrote:
> On Thu, Dec 07, 2006 at 10:21:23AM -0600, Christ, Bryan wrote:
> > As long as your not dealing with wide/mb characters, here's how I handle
> > it.
> >
> > gint32 get_keystroke(void)
> > {
> > gint32 keystroke=0;
> > gint key_code=0;
> >
> > key_code=getch();
> > if(key_code==-1) return -1;
> I understand this.
> > if(key_code!=27) /* esc sequence */
> > {
> > #ifdef _DEBUG_VERSION
> > printw(" %d ",key_code);
> > #endif
> > return (gint32)key_code;
> > }
> I also understand the above if. Now below is where it get's interesting.
> You read another key into the key_code, and assign keystroke the same
> value. Then you get another key, why? What do teh special 8 and 16
> numbers represent? I'm surprised to see 4 keys being read here. I hope
> you can shed some light on this.
>
> Thanks,
> Bob Rossi
> > key_code=getch();
> > keystroke=key_code;
> > key_code=getch();
> > keystroke=keystroke | (key_code<<8);
> > key_code=getch();
> > keystroke=keystroke | (key_code<<16);
> >
> > #ifdef _DEBUG_VERSION
> > printw(" %d %d %d ",(keystroke & 0xff),
> > ((keystroke>>8) & 0xff),((keystroke>>16) & 0xff));
> > #endif
> > return keystroke;
> > }
>
- alt key, Bob Rossi, 2006/12/07
- Re: alt key, Christ, Bryan, 2006/12/07
- Re: alt key, Bob Rossi, 2006/12/07
- Re: alt key,
Christ, Bryan <=
- Re: alt key, Pierre Abbat, 2006/12/07
- Re: alt key, Dan Nelson, 2006/12/07