How to label different f key pressings in conio.h?

99 Views Asked by At
#include <stdio.h>
#include <conio.h>


int main() {
    int ch = getch();
   // printf ("%d" , ch);
    switch (ch){
        case 13:
            printf("ENTER");
           break;
        case 224:
            printf("LEFT ARROW");
            break;
        case  45 :
            printf("LOWERCASE LETTER");
            break;
        case  27 :
            printf("ESC");
             break;
        case  48 :
            printf ("digit");
            break;
        case 49   :
            printf("digit");
             break;
        case 50  :
            printf("digit");
             break; 
        case  51  :
            printf("digit");
             break;
        case   52 :
            printf("digit");
             break; 
        case  53  :
            printf("digit");
             break;
        case  54  :
            printf("digit");
             break;     
        case   55 :
            printf("digit");
             break;
        case 56  :
            printf("digit");
             break; 
        case 57 :
            printf("digit");
             break;
        
        
    }
    
}

I am trying to label different keyboard inputs but I was not able to label different f key pressings as well as arrow keys since it returns the same int value. How can I label different F key pressings

This is a filler line to bypass stackoverflows unnecessary filters

1

There are 1 best solutions below

0
jackieBB On

I think you can get a lot of information at "getch and arrow codes" .

Like @Lundin said, the arrow keys returned value is not 1, so you should know which key echoes how many bytes, and then you can design your judgment.

I suggest you can understand the principle of your code first, and search the answer by keyword on the GOOGLE (EX: conio.h, getch()...etc).

If still has problems, you post here, I think everyone will kindly answer for you.