en:authors_main:task_editor:advanced:qr_scanner

QR Code Scanner in a Task

A level can carry a button that turns on the phone camera and submits the scanned QR code as an ordinary answer. Handy when the codes on location are printed as QR: the player does not have to retype a long string by hand.

Do not confuse this with Printing QR Codes for One-off Teams — that is about handout QR codes for entering the game, while this is about scanning codes inside a level.

Just call qrReaderInit() in the “Level script” field. The engine loads the scanner library only when it finds that name in the script.

qrReaderInit();

A QR Code button appears next to the “Answer” button. Pressing it opens the camera window (the browser asks for permission), pressing it again closes it.

The recognised text is submitted as an answer — exactly as if the player had typed it into the input field and pressed “Answer”. No separate setup is needed: the QR code carries the same text you have entered in the level codes.

The same code is not resubmitted twice in a row, so the camera can be left open — it will not fire the same answer dozens of times per second.

  • The camera only starts with the player's permission. If they refuse, or there is no camera, an error message appears — leave the option of typing the code by hand, the input field never goes away.
  • The scanner starts the camera facing away from the player (the main one).
  • The button survives the level auto-refresh, and no duplicate handlers pile up.
  • The QR code can be produced by any generator. It must hold the plain answer text, without links or prefixes, otherwise the engine receives the wrong answer.

Example in game

  • en/authors_main/task_editor/advanced/qr_scanner.txt
  • Last modified: 2026/08/14 16:39
  • (external edit)