-
Notifications
You must be signed in to change notification settings - Fork 724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating AltGr replacement keys #106
Comments
Hi Frank! If you alter the $.keyboard.layouts['french-azerty-mod'] = {
'default' : [
"\u00b2 & \u00e9 \" ' ( - \u00e8 _ \u00e7 \u00e0 ) = {bksp}",
"{tab} a z e r t y u i o p ^ $",
"q s d f g h j k l m \u00f9 * {enter}",
"{shift} < w x c v b n , ; : ! {shift}",
"{accept} {alt} {space} {alt} {cancel}"
],
'shift' : [
"{sp:1} 1 2 3 4 5 6 7 8 9 0 \u00b0 + {bksp}",
"{tab} A Z E R T Y U I O P \u00a8 \u00a3",
"Q S D F G H J K L M % \u00b5 {enter}",
"{shift} > W X C V B N ? . / \u00a7 {shift}",
"{accept} {alt} {space} {alt} {cancel}"
],
'alt' : [
"\u00b2 & ~ # { [ | ` \\ ^ @ ] } {bksp}",
"{tab} a z \u20ac r t y u i o p ^ \u00a4",
"q \u00df(alt-s):bla_bla d f g h j k l m \u00f9 * {enter}",
"{shift} < w x c v b n , ; : ! {shift}",
"{accept} {alt} {space} {alt} {cancel}"
],
'alt-shift' : [
"{sp:1} 1 ~ # { [ | ` \\ ^ @ ] } {bksp}",
"{tab} A Z \u20ac R T Y U I O P \u00a8 \u00a4",
"Q \u00df(alt+S):bla_bla2 D F G H J K L M % \u00b5 {enter}",
"{shift} > W X C V B N ? . / \u00a7 {shift}",
"{accept} {alt} {space} {alt} {cancel}"
],
}; |
Hi Rob,I have tested the demo on jsfiddle and I am afraid it does not work. When I press alt or AltGr I do see the correct keyboard with char \u00df but when I press Alt and s or alt and shift and S, no character isdisplayed in the input. I have tested all keys of the keyboard and only the e, 2, 3, 4 5 6 7 8 9 0 ° + £ keys are working these are the standard AltGr keys written on our keyboards. It seems thatall other are filtered?Do you have any other idea? Kind regardsFrank |
Hi Rob,I have analysed the problem a little further. I am using Chrome and keypress event is not triggered when I press AltGr + s. But KeyDown and KeyUp are fired with keycode (17 and then 18 for AltGr and 83 for s - tested in http://www.quirksmode.org/js/keys.html). This may be the reason why it is not working?Kind regardsFrank |
Actually the main reason why it isn't working is because Windows uses the Alt key to open the current application menu. If you are typing in a textarea/input and press Alt-F, the file menu will open. Now if you press the alt key a second time, the focus will return to the textarea/input. So really the bottom line is that Ctrl may be a better meta key to use if you want to add shortcut key strokes, but just don't try to override the default editing tools & browser shortcuts (Ctrl + z, x, c, v, a, s, etc). I did try to ask a question on StackOverflow about keys to avoid... there is a more through list there, but no real answer. |
hello Rob i am not sure that it is the main reason. on windows there is an alt key and an alt gr key. both are nearly the same except that alt is used for menu commands and alt gr is used for special characters and avoid conflicts between national keyboards and software commands (software are global even if localized) it seems to me that Mottie keyboard is listening on the key press event for normal keys and not on key down and key up kind regards Frank |
https://inexorabletash.github.io/polyfill/demos/keyboard.html |
Hi @ZaDarkSide! Thanks for sharing, that is a really cool demo... I never knew you could differentiate left & right keys! The main issue is if |
Another method is to trigger the event on the element you need and prevent the default: // with jQuery
$(anotherel).on('keypress', function(e) {
$(el).trigger(e);
e.preventDefault();
}); You can also try event.stopPropagation: event.stopPropagation(); // this is standard event.cancelBubble = true; // this is non-standard |
Sadly that doesn't seem to work. The keyboard needs to bind to "keyup", "keydown" and "keypress" events. If you prevent default on "keydown", the "keypress" event doesn't appear to fire, even if it is manually triggered. |
If you want to trigger the keypress or keydown event then all you have to do is: var e = jQuery.Event("keydown");
e.which = 50; // # Some key code value
$("input").trigger(e); http://stackoverflow.com/questions/832059/definitive-way-to-trigger-keypress-events-with-jquery |
In this case, I can't create a psuedo-event because the status of the My facts may not be 100% accurate as I have't looked at this code in a while, so don't quote me on any of this information:
I set up this demo to show you what happens when you use Also, check out this madness. |
Hello Mottie,
Your keyboard is fantastic.
I have a question about replacement keys. Is it possible to create Alt Gr replacement keys? for instance I would like to create a keyboard to write in German with a French keyboard, so I would need only a few letters like the ß but I would like also to create a shortcut a bit like you have set up with the diacritic é = '+e. I would like to use an Alt Gr + s or Alt Gr + S. Is there a way to do it? I have tried replacement keys "\u00df(alt-b):bla_bla" or "\u00df(alt+b):bla_bla". It does not seem to work.
TIA
Kind regards
Frank
The text was updated successfully, but these errors were encountered: