Board index » delphi » Function keys

Function keys

Could someone tell me what the numbers are for the following keys:
ESC
F1
ALT+L

I already know how to use the function keys - it's in the crtdemo file. But it
doesn't say how to find the numbers for function keys. Help would be much
appreciated.
~Jonathan,

 

Re:Function keys


In article <20010126045536.05767.00001...@ng-fr1.aol.com>,

Quote
Jthom10361 <jthom10...@aol.com> wrote:
>Could someone tell me what the numbers are for the following keys:
>ESC
>F1
>ALT+L

var c:char;

begin
  Repeat  
    c:=readkey;
    writeln(ord(c));
  until c=#27;
end.

Use this and hit ESC to exit.

Quote

>I already know how to use the function keys - it's in the crtdemo file. But it
>doesn't say how to find the numbers for function keys. Help would be much
>appreciated.
>~Jonathan,

Osmo

Re:Function keys


Quote
>var c:char;

>begin
>  Repeat  
>    c:=readkey;
>    writeln(ord(c));
>  until c=#27;
>end.

Thanks. BTW, when I ran the program, I got 0 followed by 59 (for F1). Does the
zero just mean that there is a # in front of the number, or would I have to put
in #059 ? Thanks again.
~Jonathan

Re:Function keys


In article <20010126105230.26049.00000...@ng-fo1.aol.com>,

Quote
Jthom10361 <jthom10...@aol.com> wrote:
>>var c:char;

>>begin
>>  Repeat  
>>    c:=readkey;
>>    writeln(ord(c));
>>  until c=#27;
>>end.

>Thanks. BTW, when I ran the program, I got 0 followed by 59 (for F1). Does the
>zero just mean that there is a # in front of the number, or would I have to put
>in #059 ? Thanks again.

NO! You get just what you got when you ran the program. You first get a
zero and then a #59. Function and cursor keys return always a zero in
front. If you get a zero you know that there is the scan code in buffer
and you MUST read it (even if you were not interested in Scan codes)

Remember the computer does not know what you want to do, you must
program it to do what you want.

Osmo

Re:Function keys


Hello.

I'm using following function to read keys:

 function     KeyCode :word;
 var
              retval :word;
                   z :char;
 begin
  retval:=0;
  If KeyPressed then begin
   z:=ReadKey;
   If z=#0 then begin
    z:=ReadKey;
    retval:=Ord(z)+$100;
   end else
    retval:=Ord(z);
  end;
  KeyCode:=retval;
 end;

Write by me ;)))
This function is good to simple read keyboard. If you want to check codes of
keys just use this little sample program:

 uses
              CRT;
 var
              theend :boolean;
                 key :word;
 const
              kEsc = 27;

 function     KeyCode :word;
 {write here code as abobe}

begin
 theend:=false;
 repeat
  key:=KeyCode;
  If key<>0 then begin
   Write('Code: ',key:5,'   Original code: ');
   If key>=$100 then WriteLn('#0 : #',key-$100) else
                                 WriteLn('#',key);
  end;
  If key=kESC then theend:=true;
 until theend;
end.

And simple press a key and see the results :)
I added view of original codes.

greets
Luke

PS: as usual, sorry for my english

Re:Function keys


"ukasz Nowicki" schreef:

Quote

> Hello.

> I'm using following function to read keys:

>  function     KeyCode :word;
>  var
>               retval :word;
>                    z :char;
>  begin
>   retval:=0;
>   If KeyPressed then begin
>    z:=ReadKey;
>    If z=#0 then begin
>     z:=ReadKey;
>     retval:=Ord(z)+$100;
>    end else
>     retval:=Ord(z);
>   end;
>   KeyCode:=retval;
>  end;

> Write by me ;)))
> This function is good to simple read keyboard. If you want to check codes of
> keys just use this little sample program:

>  uses
>               CRT;
>  var
>               theend :boolean;
>                  key :word;
>  const
>               kEsc = 27;

>  function     KeyCode :word;
>  {write here code as abobe}

> begin
>  theend:=false;
>  repeat
>   key:=KeyCode;
>   If key<>0 then begin
>    Write('Code: ',key:5,'   Original code: ');
>    If key>=$100 then WriteLn('#0 : #',key-$100) else
>                                  WriteLn('#',key);
>   end;
>   If key=kESC then theend:=true;
>  until theend;
> end.

> And simple press a key and see the results :)
> I added view of original codes.

> greets
> Luke

> PS: as usual, sorry for my english

What is your question?
Have you read the FAQ? (maybe it's already in there)  :)

Greetings. Huub.

Other Threads