DEV Community

Cover image for How to Make a Phone Vibrate Using JavaScript

How to Make a Phone Vibrate Using JavaScript

Free Programmers on August 20, 2024

In this tutorial, we’ll explore how to trigger the vibration function on a smartphone using JavaScript. This feature can be useful for creating mor...
Collapse
 
andreagelmini profile image
Andrea Gelmini

Image description

Chrome on my PC confirms api support. Too bad it can't vibrate I would have liked to make it dance a bit.

Collapse
 
free_programmers profile image
Free Programmers

logically!!!

Collapse
 
andreagelmini profile image
Andrea Gelmini

To be honest, I was expecting him to tell me that I wasn't available.
Although, the idea of making the desk dance had gassed me. :-D

Thread Thread
 
free_programmers profile image
Free Programmers

👽

Collapse
 
algot profile image
AlgoT

Watch this get abused...

Collapse
 
razielrodrigues profile image
Raziel Rodrigues

I got your point hahahahaha

Collapse
 
shricodev profile image
Shrijal Acharya

Exactly my thought 👀

Collapse
 
free_programmers profile image
Free Programmers

It works!>!

Collapse
 
free_programmers profile image
Free Programmers

Of course 🌚🌚

Collapse
 
free_programmers profile image
Free Programmers

What's?

Collapse
 
paulsanjay81 profile image
Sanjay Paul

Great tutorial! The Vibration API is a neat tool for adding a touch of interactivity to your mobile web apps. Whether you're enhancing user feedback in a game or making notifications pop, this guide covers all the essentials. Just remember to use vibrations wisely to keep your users happy and engaged!

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

Totally agree! The Vibration API can really elevate the user experience when used correctly. Do you have any examples of where you've implemented it in your projects? I'm curious to see how others are creatively using it.

PS: Commenting using AI it's the dumbest thing ever

Collapse
 
free_programmers profile image
Free Programmers

👍

Collapse
 
free_programmers profile image
Free Programmers

💯

Collapse
 
mediaformat profile image
Django

Nice, still wish this still had better support



Data on support for the vibration feature across the major browsers from caniuse.com

Collapse
 
free_programmers profile image
Free Programmers

Of course

Collapse
 
martinbaun profile image
Martin Baun • Edited

Pretty neat! It’s nice for feedback on web apps that have a unique UX. For example, you might have something that does an action on press and on long press, so if a user presses down and wait 1000ms, you can perform the long press action and vibrate to let the user know they can let go now.

I however don’t think vibration has a place in 99.9% of sites though

Collapse
 
free_programmers profile image
Free Programmers

But knowing it is not bad.
For 0.1%

Collapse
 
iainsimmons profile image
Iain Simmons

Good post, and I learnt something new today!

One thing though, you mentioned odd and even indices a couple of times, but JavaScript has zero-based indexing, so the first integer in the array is the zeroth index and technically even, the second integer is index 1 and an odd index.

But I get how it could be difficult to communicate it without confusing people. Maybe talking about the odd and even positions in the array?

Collapse
 
joaquin_cavenaghi_3f84b04 profile image
Joaquin Cavenaghi

Great article!
I'm thinking of using vibrate app for my university final paper, I need to know if it's possible to manage the intensity of the vibration as well as the time. I understand that in the current version it is not, but maybe someone knows an alternative?
greetings from argentina.

Collapse
 
dixonw45 profile image
Hadeh

great feature

Collapse
 
free_programmers profile image
Free Programmers

and practical

Collapse
 
dev-team profile image
DevTeam

👍👍👍👍

Collapse
 
free_programmers profile image
Free Programmers

❤️👍

Collapse
 
razielrodrigues profile image
Raziel Rodrigues

I will create an app with this ͡° ͜ʖ ͡°)

Collapse
 
free_programmers profile image
Free Programmers

I am waiting.
Email me after you make it.
programmersfree@gmail.com

Collapse
 
mohamed_karim_2dddebb42bd profile image
mohamed karim

Thank for sharing

Collapse
 
eliskaholwe profile image
Elis Kaholwe

And here we go !

Collapse
 
wizard798 profile image
Wizard

Wow, great article, thanks for this

Collapse
 
free_programmers profile image
Free Programmers

Glad it was helpful!

Collapse
 
techninjax profile image
Techninjax

Thanks for the updates

Collapse
 
free_programmers profile image
Free Programmers

👍

Collapse
 
code_passion profile image
CodePassion

This is a cool feature that I can definitely see adding some extra interactivity to web apps.

Collapse
 
free_programmers profile image
Free Programmers

Absolutely! It can really enhance user engagement.

Collapse
 
dansilcox profile image
Dan Silcox

Nice, can't wait for all those 'sign up to our newsletter' popups to vibrate at me :D

Collapse
 
free_programmers profile image
Free Programmers

Try Again!

Collapse
 
ddebajyati profile image
Debajyati Dey

great articles! Thanks for sharing the knowledge!

Collapse
 
free_programmers profile image
Free Programmers

👍💯🙏

Collapse
 
syedmuhammadaliraza profile image
Syed Muhammad Ali Raza

👍

Collapse
 
annavi11arrea1 profile image
Anna Villarreal

Love it! Thanks for sharing.

Collapse
 
free_programmers profile image
Free Programmers

👍

Collapse
 
roshan_khan_28 profile image
roshan khan

web games created can use this feature. great write on the vibration API.

Collapse
 
free_programmers profile image
Free Programmers

💯

Collapse
 
progkidscom profile image
ProgKids

Great!

Collapse
 
free_programmers profile image
Free Programmers

🙏👍

Collapse
 
amirmajd86 profile image
Amir Majd

It was really awesome💯

Collapse
 
free_programmers profile image
Free Programmers

Thanks 😊

Collapse
 
d9shcode profile image
Dinesh • Edited

I have used it in my todo app thanks.. good functionality
Image description

Collapse
 
free_programmers profile image
Free Programmers

The big codes were the ones that worked!!

Collapse
 
ab_arham profile image
Abdul Arham

👍