move parts of get_keyboard_height to global

Seems to give a noticable performance increase with no negative side effects. Not properly tested though