Fix guide · Computers

I press c and it appears on my screen. What really happened in between?

Illustration: a finger pressing the C key, with a dotted trail marked by amber circles 1, 2 and 3 running from the key across the keyboard, through a cable and tower, then to a letter c with a text cursor on a monitor.
Image: Tech Cheat Codes (illustration)
On this page · 10 sections
  1. Quick answer
  2. 1. The key closes a circuit
  3. 2. A tiny chip inside the keyboard notices
  4. 3. The keyboard sends a number, not a letter
  5. 4. Windows decides it's a c
  6. 5. The app writes it down
  7. 6. The screen catches up
  8. The keyboard has no idea what it typed
  9. References
  10. Want AI to answer your clients?

Quick answer

Pressing the key closes a tiny circuit. A chip inside the keyboard notices, waits a moment to be sure, and sends a number for that key's spot over the cable or Bluetooth. Windows turns the number into a letter using your keyboard layout, hands it to the app you're typing in, and the app draws it. Then Windows puts the new picture on your screen.

Press c. A c appears. You do it so often that it doesn't feel like anything happened at all.

Plenty happened. By the time that letter shows up, it has been a closed circuit, a number, a message in a queue, a decision about which keyboard layout you use, and a fresh drawing on your screen. And the letter is made the moment you push down, not when you let go.

Larry emailed us this one: "When I press the character 'c' on my keyboard, it appears on my screen. In between pressing that key on my keyboard, and it subsequently appearing on my screen, what really happened?" Good question, Larry. We'll follow one c all the way, on a Windows PC, because Microsoft documents each stop along the way.

1. The key closes a circuit

Under the keycap sit two metal contacts that don't touch. Pressing the key makes them touch, and current can flow.

Your keyboard doesn't give each key its own wire to the brain. The keys sit on a grid of rows and columns, and every key joins one row to one column. That grid is called the key matrix.

2. A tiny chip inside the keyboard notices

A small computer inside the keyboard, its microcontroller, checks the grid constantly. It powers one column at a time and reads every row to see which ones carry current. That's how it knows which key you pressed. Many keyboards add a diode at each key so that pressing three keys at once doesn't fool the chip into seeing a fourth.

Then the chip waits. Metal contacts don't close cleanly. They bounce, flickering on and off for a moment before they settle, and without a fix one press could type ccc. So the chip ignores the flicker until the key holds steady. That's called debouncing. QMK, a popular free keyboard firmware, waits 5 milliseconds by default.

3. The keyboard sends a number, not a letter

Once the press is real, the keyboard reports it. It doesn't send the letter c. It sends a number from a shared list called the HID usage tables, which the USB group that sets the standard publishes. On that list, the key in the c spot is number 6 on the keyboard page.

A wired keyboard sends that report over USB. A Bluetooth keyboard sends the same kind of report over Bluetooth, which has its own rules for carrying it. Either way, Windows has one piece of software that sits between every connection type and the keyboard driver, so to the rest of the computer they look the same. That shared standard is why a plain keyboard works the moment you plug it in, no installer needed.

4. Windows decides it's a c

Windows' keyboard driver converts the number into a scan code. For that key, it's 0x2E. Then it turns the scan code into a virtual-key code, Windows' own name for what the key is for, and drops a message about the press into a queue.

Up to now, nobody has said "c." That happens next, when the message reaches the app's message loop. A step there called TranslateMessage asks your keyboard layout what character that key makes, checking Shift and Caps Lock first. The layout answers c, or C, and Windows sends the app a second message carrying the actual character.

A press and a release are separate events, too. The keyboard reports when you push the key down and again when you let it go. The letter is made from the push, so the app gets its c before it ever hears that you let go.

5. The app writes it down

Only one window gets your typing: the one with keyboard focus, usually the one you last clicked. Windows hands the character to that window, and the app adds it to whatever you're writing, whether that's a document, a search box or a text message.

Browsers show the same split in their own words. Each key press carries two labels. One, code, names the physical key. The other, key, is the character it made after Shift and your layout had their say.

6. The screen catches up

The app redraws the part of its window where the c landed. On modern Windows, apps don't paint straight onto your screen. They draw into a hidden picture in video memory, and a part of Windows called the Desktop Window Manager stacks every window's picture into one desktop image and sends that to the display. The next time your screen refreshes, the pixels that make up the c light up.

The keyboard has no idea what it typed

The keyboard sends a spot, not a letter. On a US keyboard, the key next to Tab is Q. Switch Windows to a French layout and the same key, sending the exact same number, types an A. Switch to Dvorak and it types an apostrophe. The keyboard never finds out. Nothing changed in the keyboard. Only the computer's idea of what you meant changed.

So the c you just typed was never in your keyboard. Your finger made a spot on a grid, and the computer, checking which keyboard layout you picked, decided you meant c. Every word you type on a keyboard works the same way. The meaning was added on the computer's side, one key at a time, the instant you pressed down.

Got a tech question you can't crack? Email it to hello@techcheatcodes.com and try to stump us. Please don't send passwords or account details.

Want the next fix in plain English? Follow Tech Cheat Codes on Facebook. Tap this link, then tap Follow: Follow Tech Cheat Codes on Facebook

References

All 9 reference links

Want AI to answer your clients?

Our ready-made AI setups come with a step-by-step guide in Easy Mode and Pro Mode. You set them up yourself.

See the AI setups