Skip to main content

Bug Tracker

Side navigation

#14813 closed bug (notabug)

Opened February 17, 2014 06:50PM UTC

Closed February 17, 2014 07:02PM UTC

Last modified February 18, 2014 02:27PM UTC

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

Reported by: fernandopalad@gmail.com 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)

Attachments (0)
Change History (2)

Changed February 17, 2014 07:02PM UTC by rwaldron comment:1

resolution: → notabug
status: newclosed

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

Changed February 18, 2014 02:27PM UTC by fernandopalad@gmail.com comment:2

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.