Board index » delphi » Using the Function Keys and The Escape Key

Using the Function Keys and The Escape Key

I'm trying to find a way so that I can use the Function and Escape keys
for options on my program...

example:
        Press <F1> to See main Menu  <F2> To Place an order
        <Esc> to go back one step

Any help is appreciated...I'm using TP7.0....Thanks in advance

 

Re:Using the Function Keys and The Escape Key


In article <319CE07F.2...@postoffice.worldnet.att.net>, Lion Fan
<lions...@postoffice.worldnet.att.net> writes

Quote
>I'm trying to find a way so that I can use the Function and Escape keys
>for options on my program...

>example:
>       Press <F1> to See main Menu  <F2> To Place an order
>       <Esc> to go back one step

>Any help is appreciated...I'm using TP7.0....Thanks in advance

I have not checked but something like this should do the job

    Ch := Readkey;
    If Ch = #0 Then
       Begin
         Case Ch of
           #72 : Dec(Pointer);   {Up Arrow}
           #80 : Inc(Pointer);   {Down Arrow}
           #13 : Inc(Pointer);   {Return}
           #71 : Begin End; {Home}
           #79 : Begin End; {End}
           #73 : Begin End; {PgUp}
           #81 : Begin End; {PgDn}
           #59 : Help;      {F1}
           #60 : Begin End; {F2}
           #61 : Load; {F3}
           #62 : Save; {F4}
           #63 : Begin End; {F5}
           #64 : Begin End; {F6}
           #65 : Begin End; {F7}
           #66 : Begin End; {F8}
           #67 : Begin End; {F9}
           #68 : Xit := True; {F10}
           End; {Case}
       End;

If I remember correctly does the trick.
--
-----------------------------------------------------------------------
                                               Nigel Underhill - Xei/NU
                                               ............RECLAMATION?

Re:Using the Function Keys and The Escape Key


Using function keys (and Alt-something keys) is quite easy.
All You need is a two pass check like the one shown below.
The variable c must be of the type CHAR.

c:=readkey;
if c=#0 then
begin
  c:=readkey;
  if c=#?? then    { F1 ? }
  begin
  end;
end else
  if c=#27 then    { <ESC> ?}
  begin
  end;

The actual codes for function keys You will have to look up in the TP
manual. Some appendix most likely.

............................................................
Jan H. Hviid                            E-mail : j...@ddre.dk
Danish Defence Research Establishment
Ryvangs Alle 1,  P.O box 2715
DK - 2100 Copenhagen O.
Denmark
............................................................

Quote
On Fri, 17 May 1996, Lion Fan wrote:
> I'm trying to find a way so that I can use the Function and Escape keys
> for options on my program...

> example:
>    Press <F1> to See main Menu  <F2> To Place an order
>    <Esc> to go back one step

> Any help is appreciated...I'm using TP7.0....Thanks in advance

Re:Using the Function Keys and The Escape Key


In article <319CE07F.2...@postoffice.worldnet.att.net>,

Quote
lions...@worldnet.att.net wrote:
> I'm trying to find a way so that I can use the Function and Escape keys
> for options on my program...

> example:
>         Press <F1> to See main Menu  <F2> To Place an order
>         <Esc> to go back one step

> Any help is appreciated...I'm using TP7.0....Thanks in advance

something related does anyone know how to activate f11 and f12 ?

Bevyn.

Re:Using the Function Keys and The Escape Key


Quote
Bevyn Quiding wrote:
> something related does anyone know how to activate f11 and f12 ?

They don't need to be "activated", but you need to use an i/o function
which doesn't actively ignore them.  E.g., use BIOS function directly.

- Alf

Re:Using the Function Keys and The Escape Key


Quote
Lion Fan (lions...@postoffice.worldnet.att.net) wrote:

: I'm trying to find a way so that I can use the Function and Escape keys
: for options on my program...

: example:
:       Press <F1> to See main Menu  <F2> To Place an order
:       <Esc> to go back one step

: Any help is appreciated...I'm using TP7.0....Thanks in advance

use the keyboard scan codes, here's a few (the ones you need, too)

const
  escape = #001;
  f1     = #059;
  f2     = #060;
  ...
  f10    = #068;
  f11    = #087;
  f12    = #088;

var
  ch : char;

begin
  ...
  ch := ReadKey;
  if ch = escape then
    ...
  if ch = f1 then
    ...

you get the idea..

i made a little program to show what keyboard scan codes are for each
key, which goes something like:

program KeyTrap; { by victor dods }

uses crt;

procedure HideCursor; assembler;
asm
  mov ax,0100h
  mov cx,2607h
  int 10h
end;

procedure ShowCursor; assembler;
asm
  mov ax,0100h
  mov cx,0506h
  int 10h
end;

begin
  ClrScr;
  write('press escape to quit');
  HideCursor;
  repeat
    GotoXY(1, 2);
    write(Port[$60]); { Port[$60] is for the keyboard scan codes }
  until Port[$60] = $01;
  ShowCursor;
end.

i hope this helps..
victor dods

Other Threads