You are calling applyEvent
immediately and pass the return value to addEventListener
(which is undefined
). Since the input element doesn't have a value yet at that moment, .value
will return an empty string.
Pass a function instead:
....addEventListener("mousedown", function() {
applyEvent(event);
}, false);
(I don't know where event
is coming from in your code, but I assume it is a custom object, not the actual event object).