[vim keymap] Improve code structure for later usage

This change set is to allow the `cm to vim` key conversion logic in `handleKeyEvent_` to be reused by our later `insertMode keylogger` upon raw key events.