Implemented event handler (formerly input handler). Closes #272.