Keymaster.js: micro-library to add keyboard shortcuts
github.com
github.com
For example (and please correct me if I'm mistaken), "Copy" is "C" because it's the first letter, and "X" is "Cut" because it looks like scissors. But "V" was chosen because it's next to the two others, despite not hinting at "Paste" at all.
The reason I come up with that question is that I use a French keyboard (AZERTY) which modifies a dozen of key positions, and it makes some shortcuts hard to execute. Sometimes, they're even impossible to execute. For example, the numbers row needs SHIFT to type a number. In QWERTY, to get a "1" you just type "1" but on AZERTY you type "SHIFT+&".
I'm sure other international keyboard layouts have the same issue and wondered how those who implement those shortcuts deal with that.
Sadly, checking now on my girlfriends' QWERTZ+Hungarian version of MS Office it seems it's ctrl+F notwithstanding the sheer lack of an F in "Keresés".
document.addEventListener('keypress', function(event) {
sign = String.fromCharCode(event.charCode);
if (sign === 'A') {
console.log('Pressed shift+a');
}
else if (sign === 'c' && event.ctrlKey) {
console.log('Pressed ctrl+c');
}
});
I have tested this technique with several layouts (azerty, dvorak, bepo) and it seems to be working fine. For special keys such as enter, esc or backspace you will have to listen for 'keydown' event instead.It's not as easy as it should be to go from page to page on some sites and would be cool if there was a way to do it via the keyboard!
Noticeably, there is no access key in the prev/next links in diveintoaccessibility :)
I approve of this project name. :D