Replace input polling with input event handling