From keypress to pixel
You press a key and the letter appears a few dozen milliseconds later. See how that information travels through the computer and what slows it down.
The tool could not be loaded. Check your connection and reload the page.
Use the arrow keys to move between steps. Click a term to see what it means, or any row of the timeline.
Terms in this step
Sent
Inside the message
Certificate checks
Where the time goes
Times are typical values for illustration, not measurements.
How far things are for the CPU
If one nanosecond lasted a second, this is how long common operations would take.
| Operation | Really | If 1 ns = 1 s |
|---|
How it works
The keyboard detects the press by scanning its key matrix and waits for the contacts to settle. The computer polls it over USB (125 or 1000 times a second), so the message waits for the next poll.
The USB controller raises an interrupt, the kernel driver turns the message into a key event and the window system hands it to the active application. That takes a fraction of a millisecond.
The application handles the event and redraws. A native editor does it quickly, a web app with JavaScript and page layout more slowly.
The new frame waits for the monitor's refresh, travels over the cable and the pixels have to physically switch. On a 60 Hz monitor that is where most time goes. Timings are typical values, not measurements.
When it helps
- Understand why a gaming monitor and a 1000 Hz keyboard reduce input lag.
- Explain to students how hardware, the kernel and applications work together.
- Get a feel for orders of magnitude: CPU nanoseconds, disk microseconds, network milliseconds.
Glossary 22 terms
- Key switch
- The mechanical or membrane contact under a key that closes a circuit when pressed.
- Debounce
- Contacts bounce for a few milliseconds when they close. The firmware waits for them to settle, otherwise one press would type a letter several times.
- Key matrix
- Keys wired in a grid of rows and columns. The firmware scans it very quickly and tells from the crossing which key is down.
- Firmware
- A small program inside a device, here the keyboard. It runs on its own chip, independent of the computer.
- HID
- The USB standard for keyboards, mice and game controllers. Thanks to it a keyboard works without installing a driver.
- USB
- The bus devices plug into. The computer runs the traffic and a device may only speak when it is asked.
- Polling rate
- How many times a second the computer asks the keyboard for news. 125 Hz means every 8 ms, 1000 Hz every millisecond.
- Interrupt
- A signal with which hardware tells the processor "something happened". The processor puts its current work aside and handles it.
- Driver
- The part of the system that understands a specific piece of hardware and turns its messages into events the rest of the system understands.
- Kernel
- The core of the operating system. It manages the hardware, memory and processes and shares the processor's time between them.
- Focus
- The window or field that currently receives keyboard input. That is where the letter you type arrives.
- Event loop
- An application keeps waiting for events (a key, a click, data from the network) and handles them one by one. While it is busy, the next event waits.
- GPU
- A processor specialised in drawing. It can compute the colours of millions of pixels at once.
- Graphics API
- The interface an application uses to tell the GPU what to draw: Metal on a Mac, Direct3D on Windows, Vulkan and OpenGL elsewhere.
- Rasterisation
- Turning shapes and letters into actual pixels of the screen grid.
- Compositor
- The part of the system that combines the windows of all applications into one final screen image.
- Refresh rate
- How many times a second the monitor shows a new frame. 60 Hz means every 16.7 ms, 144 Hz every 6.9 ms.
- VSync
- Syncing with the monitor's frames: a finished image is swapped in only between two frames so it doesn't tear. That is why it waits.
- Scanout
- Sending a frame to the monitor line by line from top to bottom. The top of the screen gets it before the bottom.
- Pixel response time
- How quickly a pixel changes colour. LCD crystals need a few milliseconds to turn, OLED lights up almost instantly.
- OLED and LCD
- LCD lets a backlight through crystals that twist. In OLED every pixel emits its own light, so it switches faster and has deep blacks.
- Input lag
- The total delay from an action (a key, a mouse move) to a visible reaction on screen. It is the sum of all the steps of this simulation.
Frequently asked questions
// 01 What is input lag?
The delay between your action and the visible reaction on screen. Typically 20 to 60 ms; for gaming and typing a difference of about 10 ms is noticeable.
// 02 Does a 144 Hz monitor help for work too?
Yes. Shorter frames reduce both the wait for the refresh and the scan-out time. Compared with 60 Hz it is about 10 ms on every keystroke.
// 03 Why is RAM "slow" when it moves gigabytes per second?
Throughput is high, but every single access takes about 100 ns, hundreds of CPU cycles. That is why CPUs have several levels of cache.
You may also need
Did this save you time?
The tools and simulations are free, ad-free and need no sign-up. If they helped you, you can send a contribution for coffee and new tools.
Donate via PayPalNeed a hand?
I build and maintain web applications in Laravel and PHP. If something on these pages is giving you trouble in a project, get in touch.
Get in touch