FeXd / puzzle-chess

Find the best move.
http://puzzlechess.ca/
GNU General Public License v3.0
0 stars 0 forks source link

Audio / Tactile Feedback #10

Open FeXd opened 1 year ago

FeXd commented 1 year ago

Add "haptic feedback" (iOS term) to slightly vibrate device after each move. Consider adding audio for pieces moving as well, but could be annoying.

FeXd commented 7 months ago

JavaScript has a vibrate API: https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API

function triggerVibration() {
  if ('vibrate' in navigator) {
    // Vibrate for 500 milliseconds
    navigator.vibrate(500);
  } else {
    console.log("Vibration API not supported on this device.");
  }
}

triggerVibration();

Currently there is no support for Safari both on Desktop and Mobile.

😢