There are keys and keys. You can not read (by a scanf
) for example the combination of the A
and the B
keys at the same time, since it is not a character, it just does not exist AB
.
To use some key combination you will have to use the following: CTRL
, ALT
and SHIFT
, combined with any character key, that is, the characters A through Z.
Note that all program shortcuts are
CTRL + (A-Z)
,
ALT + (A-Z)
or
SHIFT + (A-Z)
It is also common to use the
F(1-12)
(Functions keys) keys.
In reality, some combinations of these keys emits a nonprinting character, a control character that your software can use to perform some specific function.
Compile this code and see the difference in value in key combinations with CTRL
, ALT
and SHIFT
.
#include <stdlib.h>
#include <stdio.h>
int main()
{
unsigned char key;
printf("press any key:>");
scanf("%c", &key);
printf("key pressed:>%X \n", key);
return 0;
}