How do you programmatically trigger input touch event?


I tried following:

angular.element('_input element_').tiggerHandler([_'here I tried: click, touchstart, touchend'_])

but nothing happens. Input is not focused and keyboard haven’t showed up.

Any help is appreciated! Thanks!

See this thread

Thank you, @mhartington!

And what about iOS? Can I do it with Js?

Yup, it will work just the same.

You just need to add this line to the config.xml:

<preference name="KeyboardDisplayRequiresUserAction" value="false">
1 Like

Thank you! You are awesome!

Not related with this repository,
Just want to share some information, because when when i start to learn about “tap” event this questions was top result of Google.

You can trigger TAP event with “dispatchEvent” function.
Tap is virtual event of JQuery not DOM event. It will collect following events with 300ms delay.

  1. touchstart
  2. touchend
  3. mousedown
  4. mouseup
  5. click

Following example will help to trigger touch events.

  const viewportOffset = element.getBoundingClientRect();
  const elementCenterX = (viewportOffset.left + viewportOffset.width) / 2;
  const elementCenterY = ( + viewportOffset.height) / 2;
  const touchObj = new Touch({
    target: element,
    clientX: elementCenterX,
    clientY: elementCenterY,
    radiusX: 10.5,
    radiusY: 10.5,
    rotationAngle: 10,
    force: 0,
    identifier: 0,
    pageX: elementCenterX,
    pageY: elementCenterY,

  oEvent = new TouchEvent(eventName, {
    altKey: false,
    cancelable: true,
    bubbles: true,
    changedTouches: [touchObj],
    touches: [],
    targetTouches: [],
    shiftKey: true,