?
Solved

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

Posted on 2000-03-23
4
Medium Priority
?
212 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 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