Added new keyboard handling routine (needs a little work)