some refactoring, and changed to actually hold down keys for os x