Here's the whole PS/2 keyboard driver, 42 lines of code: https://git.sr.ht/~sircmpwn/bunnix/tree/master/item/sys/arch/dev/+x86_64/ps2kbd.ha
(plus the generic keyboard driver support code): https://git.sr.ht/~sircmpwn/bunnix/tree/master/item/sys/dev/chr/kbd.ha