Viewing a single comment thread. View all comments

malank t1_j6h30mo wrote

There’s a little computer on a microchip inside your keyboard. That chip has a bunch of pins that are constantly (say 100x per second) checking the state of every single button on your keyboard. The buttons on your keyboard work like light switches; there is power on one side and it either connects the power or disconnects it.

When it sees a button state change, software on the microchip goes and looks in a table to see what code it should send to the computer.

Here the button code is sent to the computer over the wire or wireless connection. (Not ELI5: In this case the button code for the “4” key is the value “21” decimal; you can look them up in ch10 here: https://www.usb.org/document-library/hid-usage-tables-14 ).

Then the computer takes the button code and sends that text (still not the value of “4” but the character “4”) to the software that is running. This software can interpret it however it wants, basically through another lookup table. In a calculator application it will convert it to the value of “4”, in a game it might select weapon slot 4, in a document it might just output the text of “4” directly to the document without converting it.

2