Holding keys in terminal

0

Hello, on my Ubuntu 16.04, when I run a C program (as well as in the sublime), when I press a key, I keep repeating the same key until I release it. So far so good. But if I do not release this key and I press another key, that other key repeats itself and it is as if I had released the first key.

Is it possible to check whether the two keys are pressed simultaneously?

    
asked by anonymous 04.09.2017 / 02:24

1 answer

0

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;
}
    
04.09.2017 / 15:25