cleaned up keyboard handling