Input event handler