Holding keys on terminal

Hello, in my Ubuntu 16.04, at the time of execution of a program in C(as well as in sublime), when I press a key, it is repeating the same key until release. So far so good. But if I don't release that key and I Press another key, that other one keeps repeating and it's like I've released the first key.

Is there how to check if the two keys are pressed simultaneously?

Author: Carlos Adir, 2017-09-04

1 answers

There are keys and keys. You cannot read (through a scanf) for example the combination of the Keys A and B pressed at the same time, because it is not a character, it simply does not exist AB.

To use any key combination you will have to use the following: CTRL, ALT and SHIFT, combined with some character key, i.e. the characters from A to Z.

Note that all program shortcuts are o CTRL + (A-Z), ALT + (A-Z) or SHIFT + (A-Z) it is also common to use Keys F(1-12) (functions keys).

In reality some combinations of these keys emit a non-printable character, a control character that your software can use to perform some specific function.

Compile this code and see the difference of the value in the combinations of the keys 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;
}
 0
Author: gfleck, 2017-09-04 13:36:03