Topic summary
Scancode

Broadly speaking, a scancode (or scan code) is either a number or bitarray that is used by a keyboardprotocol to uniquely identify a keyboard key. Keyboards normally send scancodes to the computer to update the computer's internal keyboard state (which tracks what keys are being held down). The exact mechanism how, when and what scancodes are sent depends on the protocol.
A keyboard protocol may use other means to update the computer's internal keyboard state, such as sending a bitmap that encodes the state of keys (pressed/released). This is partially the case for a keyboard using the HID protocol when the Boot Protocol is selected. It will send the states of modifier keys encoded in a bitmap (where each bit represents a key state) alongside a scancode array of pressed keys (excluding modifier keys).