Hi!

I want to write a program that executes a particular code at key press,
where can I find documentation about that? I have example program which
doesn't work:

int
main(void)
{
        int kbdfd = open("/dev/wskbd", O_RDWR, 0);

        if (errno != 0) {
                printf("%s\n", strerror(errno));
                return 1;
        }

        int key;

        while(ioctl(kbdfd, WSCONS_EVENT_KEY_UP, &key) != -1) {
                if (key == KS_k)
                        printf("You pressed k!");
                else if (key == KS_q)
                        break;
                else
                        printf("You pressed %d!", key);
        }

        if (errno != 0) {
                printf("%s\n", strerror(errno));
                return 1;
        }

        return 0;
}

Reply via email to