Haptic Feedback

Hello all, how would I use haptic feedback in a file that is triggered by a button?

http://diagramcenter.org/adding-haptic-feedback-to-html.html

Hi Jonathan!

I’ve not used the haptic feature - but no one else has answered. So if there is a general set-up question maybe I can help. What in particular is not clear to You - where the code should go… how to trigger it?

1 Like

Jim,

Thanks for answering! Regarding how this is triggered, I’d creat a button that has an “on click,” state; clicking would trigger the phone to shake.

Thanks

Getting back to your original question of “how would I use?”

What is giving You issues?

1 Like

I need to add it to an interaction to tell a user something has changed on the screen.

Note this is not supported on iPhones. In theory you add a Run Javascript… action with code like:

// enable vibration support
navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;

if (navigator.vibrate) {
	// vibration API supported
	navigator.vibrate([500]);
}

There’s more examples here:
https://googlechrome.github.io/samples/vibration/

And this site had the browser check code:

1 Like