How does my key board work?
Perhaps this is a silly question.
When I press a key on the keyboard, I am closing a switch, then what? I know that each character is encoded in ASCII as a byte. For example if I press the "a" key, is the byte 01100001 immediately sent to the cpu. Or, is that number stored in some memory location that the kernel reads periodically? |
Hi -
1. No, when you press the "a" key, you do *not* immediately get an "a". The hardware generates a "keycode", which is the first of several steps before you finally read a letter "a". 2. No, pressing the key generates an interrupt on your motherboard, which is originally handled by the BIOS. It takes awhile before the kernel finally gets it. 3. No, the kernel doesn't poll the BIOS keyboard buffer. It simply fetches data that's already available (courtesy of the BIOS) when requested. 4. Once an application in user space requests a keystroke from the kernel, then the fun REALLY starts happening. Here's more than you probably ever wanted to know about keyboard handling "at the top of the stack": http://www.faqs.org/docs/Linux-HOWTO...ole-HOWTO.html Here's an excerpt from the article, which answers much of your original question: Quote:
|
Interesting question.
I was about to start researching this topic because I want to encrypt my keystrokes from the keyboard itself, all the way down the line... I read once where the Stunnel (vpn) program might help me. |
Quote:
Your keyboard knows nothing about ASCII. Every time a key is pressed, it emits a few bytes. Each key sends a different code when pressed and when released. These codes have nothing to do with ASCII, not even the letter keys. The kernel then gets those codes, and uses a look-up table (when you change the keyboard layout, you are actually changing this look-up table) to see which key/character the code corresponds to. |
All times are GMT -5. The time now is 07:05 AM. |