In ZX Spectrum, the keyboard can only be read by reading from the 0xfe port, while the highest 8 address lines select one of 8 groups of 5 keys. For example, if you want to scan the Q , W , E , R, and T keys, the top 8 bits of the address bus should be 0xfb :
ld bc,
This is exactly the same as:
ld a,
Some arcade machines of the 80s communicate with additional equipment, outputting more than 8 bits at a time with one out instruction - additional bits are read from the upper address lines.
source share