Solved

how to read function keys in c/c++

Posted on 2004-04-14
9
931 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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now