Event Handling
Goal: attaching device-independent event handlers to interactive elements.
When using semantic html tags, these are generally taken care of. But when we use non-semantic html for tags for creating interactive elements, like using div to create buttons or dropdowns, etc., we need to attach explicit event handlers to make them accessible to assistive technologies.
Demo:
Best practices:
- Use
onkeyup
instead ofonmouseup
- Use
onkeydown
instead ofonmousedown
- Use
onclick
instead ofonkeypress