Skip main navigation

Hurry, only 5 days left to get one year of Unlimited learning for £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

What Happens Inside Your Computer When a Key is Pressed?

What happens inside your computer when a key is pressed? Find out by watching this animation, narrated by Mac Bowley.

In this step, we’re going to look at what happens when you press a key on the keyboard.

The process of pressing a key in something like Microsoft Word and seeing it displayed on the screen is a good demonstration of what a computer system is: a set of devices that input, process, output, and store data. It illustrates how the hardware on a computer communicates with the software and vice versa.

The sequence of events when you press a key is as follows.

The Key is Pressed

As the key is pressed, a switch closes and current flows into a small chip in the keyboard.

Each key on the keyboard has an associated number, called a scan code. The number is based on where the key is on the keyboard. This is useful when it comes to keyboards that have different layouts and/or symbols. This scan code is sent into the computer as a binary number.

A Number is Transmitted to the CPU

The binary data is transmitted from the keyboard to your computer.

The route the data takes will depend on how your keyboard is connected to the computer. If it’s attached by a USB cable, it will go to the USB port. If the keyboard is connected by Bluetooth, it will go to the Bluetooth receiver.

The data then travels to the brains of the computer: the CPU.

The Data is Interpreted by the Operating System

Remember, the CPU is running the operating system. The operating system is constantly checking for key presses. It may look like it’s sitting there doing nothing, but the operating system must react immediately to key presses, so it has to be ready for them all the time.

An Event is Created by the OS and Captured by Application Software

The operating system will convert the scan code into an ASCII or Unicode character based on the key pressed. You typically set the keyboard layout for your computer in the operating system, so it is the operating system that will know what letter is represented by, say, scan code 1 in this language/keyboard layout.

The OS creates an event depending on the resulting character. In computing, an event is an action that is recognised and handled by the software. It often originates from the hardware.

The OS must now send the event to the appropriate application. Many different applications are running, and the key press must be handled by the right one. The OS knows what software was active when the key was pressed, and sends the event to that application.

The application software in this example is Microsoft Word. It captures the event from the operating system.

The Application Software Displays the Character on the Screen

Microsoft Word converts the character into an image based on your font choices in Microsoft Word.

It sends this image, as a binary representation, back to the CPU, which sends it to the GPU. The GPU translates the binary code into an image and displays it on the monitor.

A lot happens when you press one key. The main devices we’re going to focus on in the next few steps are input and output devices. Can you work out which device is the input and which is the output in the scenario above? Can you work out what is hardware and what is software?

This article is from the free online

Understanding Computer Systems

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now