mervick / emojionearea

Emoji Picker Plugin for jQuery
https://jsfiddle.net/mervick/1v03Lqnu/765/
MIT License
953 stars 257 forks source link

keypress not working #445

Closed Pok4 closed 2 years ago

Pok4 commented 2 years ago

hello guys, im using version 3.1.8 and i do this:

   var emojionestrip = $('textarea[name=com_text]').emojioneArea();

  var eventHandler1 = function(button, event) {
    console.log('event1');
  }
  emojionestrip[0].emojioneArea.on('paste', eventHandler1);

its working correctly, but when change 'paste' to 'keypress' on last line, the code not works.. Why keypress event didn't work ?

PS: jquery version is 3.2.1

Pok4 commented 2 years ago

I see other topics, but can you give me best alternative to this date?

sosherof commented 2 years ago

Try using "input" instead. That'll cover keyup and paste events. Keypress isn't supported by all browsers.

mervick commented 2 years ago

There is a bug with "keypress" event (https://github.com/mervick/emojionearea/issues/30),
try to use "keyup", or attach "keypress" directly to input, e.g.

$("textarea[name=com_text]").emojioneArea({
  events: {
    ready: function() {
      this.editor.on("keypress", function(event) {
        console.log("press", event);
      })
    }
  }
});

example: https://jsfiddle.net/mervick/79wLzvdm/

Pok4 commented 2 years ago

Thank you, guys :)