Board index » delphi » ALT & ALT-GR key

ALT & ALT-GR key

Hi!

How can I fidn out, wether the ALT or the ALT-GR key is pressed?
I can find out all other keys, but not this two.

Dirk

 

Re:ALT & ALT-GR key


Quote
Dirk Kisch wrote:
> How can I fidn out, wether the ALT or the ALT-GR key is pressed?
> I can find out all other keys, but not this two.

ALT and ALT-GR belong to the special keys, that also contain SHIFT,
CAPS, .. . They cannot be checked by using readkey, you have to check
them on your own. Try this piece of code:

PROCEDURE GetSchiftState;
var schif : byte;
    regs  : registers;  
BEGIN
 regs.AH := 2;
 Intr($16,Regs);
 schift := Regs.AL;
 if  Schift  AND    1  =  1  then  Rsch  :=true  else Rsch  := false;
 if  Schift  AND    2  =  2  then  Lsch  :=true  else Lsch  := false;
 if  Schift  AND    4  =  4  then  Strg  :=true  else Strg  := false;
 if  Schift  AND    8  =  8  then  Alt   :=true  else Alt   := false;
 if  Schift  AND   16  = 16  then  scroll:=true  else scroll:= false;
 if  Schift  AND   32  = 32  then  Num   :=true  else num   := false;
 if  Schift  AND   64  = 64  then  caps  :=true  else caps  := false;
 if  Schift  AND  128  =128  then  ins   :=true  else ins   := false;
END;
{ Please do not complain about the structure of this code... It's pretty
old and I don't have the time to re-format it now... sorry! }

This will help you to check, whether one of these keys is pressed or
not. Unfortunatley, (with this method) you cannot decide whether ALT or
ALT-GR is pressed... To do this, you have to hook the keyboard int, but
this is a bit more complicated...

Hope, this helps at least a bit!
--
Arno Fehm (af...@bigfoot.de)

------------------------------------------------------------------------
Member of Grey Dreams Design: visit http://GreyDreams.home.pages.de !!!!
He who can destroy a thing has the real control over it. (Frank Herbert)
------------------------------------------------------------------------

Re:ALT & ALT-GR key


Quote
Dirk Kisch wrote:

> How can I fidn out, wether the ALT or the ALT-GR key is pressed?
> I can find out all other keys, but not this two.

I AM NOT SURE with you computer, but on mine AltGR is the same as
ALT+CTRL. I remember that it was necessary on older kbd's having
no ALT-GR to press ALT and CTRL simultaneously. I tried it here:
\
as you see, it works well...

But I did not check if this is visible at $0040:$0017 too.
:-) Franz Glaser
http://start.at/tp-links  (some adverti{*word*224}t :-)
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
http://members.eunet.at/meg-glaser/           mailto:meg-gla...@eunet.at
http://www.geocities.com/~franzglaser/ http://members.xoom.com/f_glaser/

Other Threads