Refactor key event handler so we don't have to cache value of 'this'