Function to get keycode from char