How to make button accessible with keyboard
Like when user click on the tab button the focus will go on button and if click on enter the button link will open.
Like when user click on the tab button the focus will go on button and if click on enter the button link will open.
Hi,
This is plain JS. One of the options is to use an anchor element (<a>) instead of a button element and style it to look like a button. Otherwise, you just need to add a listener to your button element to react to a key press event, ensuring the key is either the spacebar or enter button, and invoke whatever action is needed. If the button is not part of the document navigation, ensure you include it by using tabindex.
Here you have an example of the latter option:
https://www.w3schools.com/howto/howto_js_trigger_button_enter.asp
https://stackoverflow.com/questions/8940714/set-tabindex-for-button-not-working
Hope this helps
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.