Is this homework?
There is no such thing as a "keyboard device file". Usually, the standard input is used for this purpose. If you need each individual keypress, you also need to use either ncurses (curses) or the termios interface (to disable canonical mode and turn off echoing, see man termios). Normally input is line-buffered, so your program does not receive individual keypresses, only complete lines, from a terminal.
If you are writing an X11 application with a graphical user interface, then you use the X11 interfaces, not system calls. Even then there is no keyboard device; keypresses and -releases and mouse movement (and many other things) are reported as events. Events are queried from the X11 server using XNextEvent; function see the manpage for details. The net is full of X11 example programs, too.
|