Custom binding for long click

I want to create a custom event called lngclick - that will fire only if the mouse is clicking on an element for a long period of time.

I would like to use it like this:
<button lngclick.delegate="myFunc()"></button>

(just like native DOM events)
aurelia custom attribute is expecting a value as bind, but I want to use delegate just like native events capturing.

someone here have already made something similar?


I think you answered it yourself with “just like native DOM events”

All that command does is to add event listener specified. If you wish to use the same command, i think you will have to go for trigger and a binding behavior or implement a new command in SyntaxInterpreter

1 Like

sounds good.
is there a demo/article/tutorial/blog post on SyntaxInterpreter?

1 Like

Unfortunately no blog/article that I could fine. But i have made this that pokes SyntaxInterpreter. Maybe you can have a look for an example there. Let me know if you have any q :smile:


ok great.
thanks for your help.

I ended up going an easier path.
I liked what long-press-event did here
by adding a listener to the document, you can catch and emit long-click events that can be used like regular DOM events by aurelia.

I also created a plugin for other to benefit.


That’s awesome. Would be even more if you could list it in aurelia-awesome in here or contribute it to :smile:

And tbh, it feels like a more proper way to do it to me.

1 Like