Well, you answer a question - "code and data kernel
". This is not API code.
A long time ago on habré article about what actually happens when you press a key on the keyboard
Read it again (if not read). Try to understand that every OS does a lot of work, processes, events and interrupts from equipment and subsystems.
When compared with the context of the article: as I write this response to You in the browser it looks like the event "pressed next button". And up to this point was an interrupt from the keyboard and transfer data from the controller and much more... in the end was the kernel, the results of which this event came just in the browser (only worked here API).