Solved

how to read function keys in c/c++

Posted on 2004-04-14
9
943 Views
Last Modified: 2012-08-13
hi all,
 how to read function keys like arrow keys,ctrl,alt,f1,f2...etc in c/c++.
i tried with getch(),but it is working with other characters(may be not sure but i thinks it works for printable characters).plz help me...

bye
ramu
0
Comment
Question by:ramuguda
9 Comments
 
LVL 12

Expert Comment

by:stefan73
ID: 10821805
Hi ramuguda,
I you are on Windows, the probably easisest way should be DirectInput.

Cheers,
Stefan
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10821841
You can use bioskey() if you are using Borland's compilers,either Borland C++ or TurboC++
You need bios.h for this.
If you have this header,post back if you need more details,
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10821860
#include<conio.h>
#include <stdio.h>
#include <bios.h>
int main(void)
{
   int key;
   clrscr();
   while (!bioskey(1));
   /* function 1 returns 0 until a key is pressed */
   /* function 0 returns the key that is waiting */
   while(key!=283)//loop till escape pressed
   {
   key = bioskey(0);
   printf("%d\n",key);
   }
   return 0;
}
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ssnkumar
ID: 10822220
If you are on Linux, you will have to use ncurses library to achieve this.

-ssnkumar
0
 

Author Comment

by:ramuguda
ID: 10829388
hi ankuratvb,
 i don't have bios.h header file...i am using dev c++ compiler and vc++ compiler...i am workin on windows operating system...how can we read function keys without using header file(bios.h)...

 can you tell me where can i download turbo or borland compilers...

bye
ramuguda
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10829569
I wouldnt really recommend you downloading these older compilers.
I am sure there are ways to do this in VC as well.Just wait,

If nothing happens,then try out these compilers:

Turbo C version 2.01 can be downloaded from http://community.borland.com/article/0,1410,20841,00.html 

I guess version 3 is also available.Visit their site.
0
 

Author Comment

by:ramuguda
ID: 10830228
hi ankuratvb,

 iam getting it in turbo c compiler...but if i copy the bios.h into include folder of vc++ compiler..iam getting linking error like...
unresolved external symbol "int __cdecl bioskey(int)" ...

 can you tell me how can we read these function keys without using this header file...i want atleast reading arrowkeys...

bye
ramuguda
0
 
LVL 9

Accepted Solution

by:
ankuratvb earned 50 total points
ID: 10832552
Hi,
Just copying the header wont do.You need the library as well which is dif. for dif. environments and compilers.

If you only want arrow keys,getch() will work:
72,75,77,80 are the codes for up,left,right and down arrow keys.
0
 

Author Comment

by:ramuguda
ID: 10836653
hi ankuratvb,
 thanks...can you tell how can we read other function keys with out using header files...

bye
ramuguda
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

679 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