{{indexmenu_n>35}} ====== 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 [[en:authors_main:hosting:qr_codes|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**. ===== How to Enable It ===== 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. ===== What Happens When Scanning ===== 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. ===== Worth Remembering ===== * 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. [[https://qeng.org/game.php?jump_to&gid=3493&task_id=78461|Example in game]]