Isolate the handler function to we can use it in both keydown and click event.