Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#14813 closed bug (notabug)

Event.which always return 'undefined' in .on('input')

Reported by: fernandopalad@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

Description

Hello guys,

I have a specific problem in the startup I'm working on that is solved by the following jQuery method:

.on('input', function(){   });  

The 'input' event trigger every action inside an input or textarea (copy, paste, focus, keyup [I think]). The thing is: I didn't want an alternative to this method, I already solved my problem using a 'quick fix', I just want know why the following doesn't work or why this isn't implemented.

I need get the keycode (or 'which') when this event is fired, but this doesn't work - always return undefined, no matter the circustances. Following is the code I'm using to test this:

var input = jQuery("#post-input");

input.on('input', function(event){
    setTimeout(function(){
        eventKeyCode = window.event ? event.keyCode : event.which;
        console.log(eventKeyCode);
    }, 200);
});

You can also see my fiddle here.

jQuery 1.10.2
Chromium 32.0.1700.102 (Chrome too, but I doesn't remember the version - one of the most recent)
Elementary OS Luna (based on Ubuntu 12.04)

Change History (2)

comment:1 Changed 6 years ago by Rick Waldron

Resolution: notabug
Status: newclosed

Platform "input" events don't provide a which, keyCode, char, or charCode.

comment:2 Changed 6 years ago by fernandopalad@…

But my question is, if all triggers have it, why "input" won't? Can you add this feature to input? Would be awesome, please, think about that.

Note: See TracTickets for help on using tickets.