0

i want ask about accesskey how i can remove alt, i have this code

<a id="button_new_order" accesskey="n"><img src="view/image/pos/new_off.png" title="<?php echo $button_new_order; ?>" alt="<?php echo $button_new_order; ?>"/></a>

so my acces key is n and i must press alt + n to get new order but i like to use n only cause make easy. how can i do that thanks. as for now im already know how to use accesskey on html but for make it simple i still dont know.

Airo Dump
  • 91
  • 1
  • 1
  • 6
  • Accesskeys have to be combined with `Alt` or `Alt + Shift`. It depends on browsers. – Praveen Kumar Purushothaman Oct 15 '14 at 14:35
  • 1
    If you do not want the user to have to press alt, than you will need to add JavaScript to the page and listen for key presses and do all of the work. – epascarello Oct 15 '14 at 14:38
  • The `accesskey` attribute works *against* accessibility by messing up software-specific accesskey assignments. Consider arranging things so that the Enter (Return) key can be used to proceed to next step. – Jukka K. Korpela Oct 15 '14 at 16:22

3 Answers3

2

Accesskeys have to be combined with Alt or Alt + Shift. It depends on browsers. To see the complete list of access keys, you can see this article in Wikipedia: Access Key or in MDN: accesskey.

But if you would like to use keyboard shortcuts, which are different from the access keys, you can use a JavaScript alternative plugin like:

  • jquery.MouseTrap: A simple library for handling keyboard shortcuts in Javascript.
  • jquery.hotkeys lets you watch for keyboard events anywhere in your code supporting almost any key combination.

There's also another StackOverflow question that focuses on this - Keyboard shortcuts with jQuery.

Community
  • 1
  • 1
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
1

you could just add a keydown listener on the whole body and listen for 'n' presses:

$(document.body).on('keydown', function (keyVent) {
    if (keyVent.which === 78) {
        // n was pressed...do stuff here
    }
});
0

alt can't be removed as default accesskey event handler

Chris P
  • 63
  • 8