KEYDOWN and KEYUP don't take the character that was typed. KeyCode is an indication of the keyboard key that was pressed.

what do you expect your function to take as characters don't map to keycodes?

also, why do you want to do this?