M
M
microbot2021-06-22 09:11:08
JavaScript
microbot, 2021-06-22 09:11:08

How to catch a keystroke from a Bluetooth headset using JS in a browser?

Hello. On sites with radio and music (not all), the player can turn on (play / pause) after pressing the on / off button. on a Bluetooth headset. But listeners onclick, onkeydown, etc. do not catch such an event. For example, this works on Yandex.Music or on this site. The volume buttons, when pressed for a long time, begin to add / decrease the sound (but on Windows). How does such a mechanism work on these sites, how to make it possible to process button presses of the Bluetooth headset on your site?
Purpose: Press the button on the headset to run the script/action in the browser on the computer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-06-22
@microbot

https://web.dev/media-session/
You hang up the play/pause event handler. And these events are also called when you click on system controls in the OS and when you press keys on headsets, and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question