Updated event handling hook for HTML