Moved keyhandling into appropriate class