Using function keys 
Author Message
 Using function keys

I've only just started using turbo Pascal in the last couple of days.

So far I'm finding it pretty easy...

But what i need to know is how to define function keys...

What I'm wanting to know is how to tell if a function key has been
pressed when the user is inputting data. I can't seem to find anything
of use at all in the manuals and it's really getting to me cos
everything else seems so simple...

If someone could help me out that'd be really kewl.



Wed, 18 Jun 1902 08:00:00 GMT  
 Using function keys

Quote:
> What I'm wanting to know is how to tell if a function key has been
> pressed when the user is inputting data. I can't seem to find anything
> of use at all in the manuals and it's really getting to me cos
> everything else seems so simple...

> If someone could help me out that'd be really kewl.

   Sure, "kewl".  <sigh>
   Anyway, this is a very common request, and it's surprising to me that
no one reads the manual information about ReadKey - which is how this is
done.  Whatever...
   The easiest way to read/process the special/extended keys is to use
ReadKey, which _only_ returns keyboard keystrokes - it doesn't echo them
like Read/Readln.  IOW, you will be creating your own keyboard "readln"
routine when using ReadKey, but that's quite simple...and it lets you
see/process the special/extended keys (function keys among them).  Here's
an example:

Uses CRT;
var C1,C2 : char;
    S     : string;
...
  S := '';                             { initialize string }
  repeat
    C1 := ReadKey;                     { fetch a keystroke }
    case C1 of             { process it, whatever it is... }
     #00 : begin  { special/extended key - fetch scan code }
             C2 := ReadKey;
             case C2 of      { process scan code character }
               #59 : do_F1_key;
               #60 : do_F2_key;
               #71 : do_Home_key;
               else                               { ignore }
             end
           end;
     #08 : if Length(S) > 0 then    { BackSpace processing }
             begin
               Dec(S[0]); write (#08#32#08)
             end;
     #27 : ;                                      { Escape }
     #13 : ;                                         { c/r }
     'A'..'Z',
     'a'..'z',
     '0'..'9' : begin                   { valid characters }
                  S := S+C1; write (C1)    { append & echo }
                end;
     else                                         { ignore }
    end  { case }
  until C1 = #13



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Source Code For Using Function Keys or Cursor Keys - Help :)

2. Source Code For Using Function Keys or Cursor Keys - H

3. Using the Function Keys and The Escape Key

4. using enter key instead of tab key for data entry

5. Function keys

6. Reading function/cursor keys

7. Reading the Function keys

8. how to read a function key press?

9. Function keys (TP7.0)

10. about keyboard arrows and functions keys

11. Timer function and Key events

12. Function Keys

 

 
Powered by phpBB® Forum Software