Why does my keyboard type the wrong characters?
Almost always because the software keyboard layout does not match the physical keyboard, so the system is interpreting each key according to a different map from the one printed on the keys.
The classic symptoms of a UK keyboard set to US layout:
@ and " are swapped. Pressing Shift+2 gives @ instead of ", and Shift+' gives " instead of @.
The £ sign produces # instead.
The backslash and hash keys behave oddly, and the UK keyboard's extra key near the left Shift does nothing useful.
This is the single most common instance, and it appears constantly after installing an operating system, restoring a backup or connecting a keyboard bought abroad.
How to fix it. Change the input language or keyboard layout in system settings to match the physical keyboard — United Kingdom for a UK keyboard, United States for a US one. Note that region and keyboard layout are separate settings, and setting the region alone does not change the layout.
Other causes worth checking:
Accidental layout switching. Both Windows and macOS have a keyboard shortcut cycling between installed layouts — on Windows commonly Windows+Space or Alt+Shift. It is easy to trigger by accident and baffling if you do not know it exists. Removing unused layouts entirely prevents recurrence.
Num Lock off on a compact or laptop keyboard, turning part of the letter area into a numeric keypad — so typing letters produces digits.
Sticky Keys or Filter Keys enabled accidentally, usually by pressing Shift five times, which triggers a prompt people dismiss without reading.
A stuck modifier key. A physically stuck Ctrl, Alt or Fn makes every keypress do something unexpected.
Dead keys in layouts designed for accented characters, where an apostrophe or quote waits to combine with the next letter and appears to do nothing.
Genuine hardware failure — liquid damage or debris — typically affects specific keys consistently rather than changing which character appears.