Solved

how to read function keys in c/c++

Posted on 2004-04-14
9
925 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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 and use pointers in the C programming language.
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.

708 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

17 Experts available now in Live!

Get 1:1 Help Now