JSFiddle - React, Tailwind, and code Playground

by Mathias Bynens

HTML

<input autofocus>

JavaScript

$.fn.input = function(fn) {
    var $this = this;
    if (!fn) {
        return $this.trigger('keydown.input');
    }
    return $this.bind({
        'input.input': function(event) {
            $this.unbind('keydown.input');
            fn.call(this, event);
        },
        'keydown.input': function(event) {
            fn.call(this, event);
        }
    });
};

$('input').input(function(event) {
  alert(this);
  alert(event.type);
});

$('input').input();