Solved

how to read function keys in c/c++

Posted on 2004-04-14
9
934 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I test for current date? 9 102
Adjust Mfcapp 29 166
C dll call freezes 5 101
Raspberry Pi 3 to send text message 9 114
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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

773 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