Member-only story
Using Flash or Torch with Html5 QR code library
Learn how to use torch with Javascript QR scanning library on Smartphones or enabling torch with camera in general using JS.
html5-qrcode is a fairly used open source library for implementing QR Code or Bar-Code scanner in a web application. It has 400K+ downloads on Github and going around 31K downloads/week on NPM.
I authored this library in my university days and have been maintaining this project since 2014 (If I remember correctly).
Enough bragging, coming back to the topic …
Almost all smartphones today come with camera which is coupled with a flash light. It’s also used as a torch while recording videos. Most QR scanning applications that are available on Android or IOS have support for enabling torch while scanning. This seems useful when scanning a code in low light conditions.
The feature request
There was a feature request on the project Github tracker for adding the same functionality to html5-qrcode library.
Since this is very interesting use-case — as it shows the power of web around controlling low level hardware on smartphones.
I decided to add support for this feature!