Solved

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

Posted on 2000-03-23
4
211 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 75 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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