-1

how many ways to trigger enter keypress keyboard event?

tried something but did not working all in my case.

Tried below.

1)
var e = new KeyboardEvent("keypress", {bubbles : true, cancelable : true, key : "13", char : "13", shiftKey : true});
    target.dispatchEvent(e);

2)
es = jQuery.Event("keypress", { keyCode: 13, which: 13});
    jQuery(target).trigger(es);

3)
$(target).trigger(
            jQuery.Event( 'keypress', { keyCode: 13, which: 13 } )
        );

Somebody knows other ways?

  • can you create a fiddle http://jsfiddle.net/ – gurvinder372 Dec 08 '15 at 07:58
  • 1
    Maybe this post is about the same: [http://stackoverflow.com/questions/3368578/trigger-a-keypress-keydown-keyup-event-in-js-jquery](http://stackoverflow.com/questions/3368578/trigger-a-keypress-keydown-keyup-event-in-js-jquery) – Orell Buehler Dec 08 '15 at 07:58

1 Answers1

0

So here is a Code-Example from the jQuery API:

var e = jQuery.Event("keydown");
e.which = 40; //keycode
$(document).trigger(e);
Orell Buehler
  • 116
  • 2
  • 9