I am using a generic usb keyboard, Linux 2.6.27 with gnome desktop, gnome-terminal and bash shell. I am interested to know what happens in the software. How are special characters from my keyboard interpreted with some encoding to characters and where do the character pictures come from?
views:
198answers:
2What is the actual path of actions happening when I press a key on keyboard and it shows on a shell?
Look at it in layers. First is the hardware, and a device driver in the Linux kernel will have specific methods for controlling and responding to the keyboard via status registers in the device and interrupt handlers, for example.
Next is the Linux kernel, which will have some method of loading the appropriate driver for each piece of hardware detected at boot time. Once loaded, the device driver conforms to some kernel-driver interface, providing data from the device to the kernel and vice versa.
Outside the kernel, at some level, the device driver and hardware are visible, usually as a listing in the /dev directory. Software, like a terminal emulator, that needs to use a device will gain access to the device through an entry in /dev.
Communication between a user-level application and the device now happens via a series of read/write and ioctl operations. These trap into the kernel (see the manual pages for these for some detail), at which point the kernel communicates with the device driver loaded above.
The terminal emulator will display characters as you type them (in most cases) and as they are received from the device (in most cases) by using fonts that it can access, located in various places depending on the application. (I'm speaking in generalities here because I don't know Gnome specifically).
Does this help?