My Problem is the following:
I want to make a program, a simple text-editor, which can work with all keys of a keyboards set such as the Function Keys (F1 to F12), Command, Left-Shift, ALT or TAB.
More precise, I want to be able to assign all keys to specific operations.
I have made a program to print out the ASCII values of those keys, but the keys doesn´t get accepted as i want to, my test program prints out either values of several ASCII codes or doesn´t accept it all like by pressing the Command Key, instead:
My test-program to print out the ASCII-value of a pressed key:
#include <stdio.h>
int main (void)
{
char k;
printf("\n\n\n\n");
while(1)
{
printf("Please press any key:");
k = getchar();
getchar();
printf("ASCII code of given input key: %d",k);
printf("\n\n\n");
}
}
Output after pressing on F2-Key:
Please press any key:^[OQ
ASCII code of given input key: 27
Please press any key:ASCII code of given input key: 81
Output after pressing on F2-Key:
Please press any key:^[[15~
ASCII code of given input key: 27
Please press any key:ASCII code of given input key: 49
Please press any key:ASCII code of given input key: 126
Output after pressing on Command-,Alt- or Left-Shift-Key:
Please press any key: // no reaction at all
Due to the fact, that i think this must be done easily, because of course its normal to use all keys of a keyboard within a program, it isn´t quite so easy for me as a newbie to find the proper way to achieve that.
I have found that question here on Stackoverflow but it belongs to C#: Special keys on keyboards
Why i can´t fetch an ASCII value of those keys?
Sorry, if i might have an mistaken impression that these keys belong to ASCII values.