Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I get Function keys to be recognised?? e.g. F1

Posted on 2000-03-23
4
Medium Priority
?
214 Views
Last Modified: 2010-04-16
I am a beginning pascal programmer. I need to know how to get pascal to recognise the Function buttons (e.g.F1, F2 etc.)
I am going to use a case statement for a menu and the function keys are the keys I need to use.
PLEASE HELP
THANKYOU
0
Comment
Question by:Waulsy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:Waulsy
ID: 2652185
Adjusted points from 50 to 75
0
 
LVL 12

Accepted Solution

by:
Hypo earned 225 total points
ID: 2652299
Here's a sample code for you that I made. Some keys on the keyboard are extended and some of the keys are not extended. When you receive a scancode for an extended key, the scancode will be preceeded by a 0. If it's not an extended key, the scancode will come alone.

So... check the GetKey function I've made, it holds the information you need be able to identify these keypresses.  

Program GetKeys;
uses crt;

var Ext : boolean;
    Key : byte;

Procedure GetKey;
begin
  Key := ord(Readkey);
  if Key = 0 then begin
   Key := ord(Readkey);
   Ext := true;
  end else Ext := false;
end;

begin
 ClrScr;
 repeat
  GetKey;
  GotoXy(1,1);
  Writeln('Key: ',Key:3,'  Extended: ',Ext:5);
 until Key = 27;
end.
0
 

Author Comment

by:Waulsy
ID: 2652601
GOOD PROGRAM I LIKE.
But how do I implement that into a CASE statement to say when this key(F1) is pressed do THIS???
0
 
LVL 12

Expert Comment

by:Hypo
ID: 2656282
You really shouldn't have to ask a new  question about this. But since you did, I'll post this answer in the new questions aswell as this one, and let you decide wether or not you want to give away those points. ;)

Here's the example:

Program GetKeys;

uses crt;

var Ext : boolean;
    Key : byte;

Procedure GetKey;
begin
  Key := ord(Readkey);
  if Key = 0 then begin
   Key := ord(Readkey);
   Ext := true;
  end else Ext := false;
end;

begin
 ClrScr;
 repeat
  GetKey;
  GotoXy(1,1);
  clreol;
  Write('Key: ',Key:3,'  Extended: ',Ext:5,' - ');
  If Ext then
  { F1..F10 are extended keys and have the scancodes between 59-68 }
   Case Key of
    59 : Writeln('You pressed F1');
    60 : Writeln('You pressed F2');
    61 : Writeln('You pressed F3');
    62 : Writeln('You pressed F4');
    63 : Writeln('You pressed F5');
    64 : Writeln('You pressed F6');
    65 : Writeln('You pressed F7');
    66 : Writeln('You pressed F8');
    67 : Writeln('You pressed F9');
    68 : Writeln('You pressed F10');
   end;
 until Key = 27;
end.

Hope it helps,
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
Let's take a look into the basics of ransomware—how it spreads, how it can hurt us, and why a disaster recovery plan is important.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question