Depends on what your OS provides. If it's your OS, you can use anything you write.
Possibilities include checking the keyboard controller or a serial port, depending on what input you want. If your OS runs in 8086 Real Mode, you can ask the BIOS for these, otherwise you need to do direct port I/O.
If you want to program the BIOS, check the RBIL. In fact, do check it, no matter what you do.
If you want to talk directly to the KBC (keyboard controller) or UART (serial port controller), I suggest looking at how other OSes do it and reading the docs on e.g. osdev.org and the OSdev Wiki.
If you’re in Real Mode, then you can call the BIOS to wait for a keypress and read it from the keyboard buffer:
MOV AH,00h
INT 16h
The ASCII code is in AL
and the scancode in AH
. But if you’re not in Real Mode, there is no keyboard buffer to begin with. A keyboard driver would get the data via direct port I/O to the keyboard controller from the KBC interrupt handler, then (and buffer by itself).