Home > Back-end >  How to use the function keys in C (F1, F2,...) to manipulate?
How to use the function keys in C (F1, F2,...) to manipulate?

Time:11-25

Because I use is vs2017, no BIOS. H this header file, cannot use bioskey, inquire of bosses, what method to be a management system, at the end of this term need f1 f2 f3... To manipulate

CodePudding user response:

Fyi:
 # include & lt; Conio. H> 
#include
Int main () {
int k;

While (1) {
If (kbhit ()) {
K=getch ();
If (0==k | | 0 xe0-0xfc==k) k=k<8 | getch ();
If==k (27) break;//press the Esc key to exit the
Cprintf (" \ r \ n % 4 x \ r \ n ", k);
}
Sleep (200);
Cprintf (". ");
}
return 0;
}

CodePudding user response:

The sample program, deal only with numeric keys, alphabetic keys, as well as the F1, F2, only supplies the reference:
 # include & lt; Stdio. H> 
#include
#include

Int main (void)
{
Int c;

While (1)
{
C=getch ();
If (c==3) break;
If (isalnum (c)) printf (" % \ n "c, c);

If (c==0)
{
C=getch ();
If (c==59) printf (" F1 \ n ");
If (c==60) printf (" F2 \ n ");
If (c==61) printf (" F3 \ n ");
If (c==62) printf (" F4 \ n ");
If (c==63) printf (" F5 \ n ");
If (c==64) printf (" F6 \ n ");
If (c==65) printf (" F7 \ n ");
If (c==66) printf (" F8 \ n ");
If (c==67) printf (" F9 \ n ");
If (c==68) printf (" F10 \ n ");
}

If (c==224)
{
C=getch ();
If (c==133) printf (" F11 \ n ");
If (c==134) printf (" F12 \ n ");
}
}
return 0;
}