I would like to start an action (enable autocomplete) when the user enters "@". However, I do not know how to do it right. I have jQuery.
Usually on a QWERTY keyboard, it looks like this:
$('textarea').live('keydown', function(e) {
if (e.which === 50) {
console.log('@ has been entered.');
}
});
However, it does not work correctly on the AZERTY keyboard. KeyCode = 50 corresponds to a key é~/2. To enter "@" in the AZERTY keyboard, this is AltGr + à@/0.
Edit: I was not clean. Autofill begins when you type @, and only after that. For example, when someone enters “Hello @”, then he starts, but when he types “Hello @nothing else”, he won’t do anything. Example: http://mrkipling.github.com/jQuery-at-username/ (it only works on the QWERTY keyboard).
source
share