AOSP dev here, really nice work!
About the keypad, normally key presses are reported to apps by the system as key events (pressed, released etc) and keycodes. There is a mapping between hardware keys and software key codes that can be overridden through kcm files.
More about this here: https://source.android.com/docs/core/interaction/input/keybo...