# registerForDeviceData Method The registerForDeviceData method registers a listener for a keyboard emulation device. Syntax
    SiteKiosk.RootApp.registerForDeviceData(deviceName,callbackFunc)
Parameters
deviceName | String that specifies the name of the keyboard emulation device.
callbackFunc | Callback function that will be called after receiving input from device.
Return Value None. Remarks The callback function has two parameters containing the data recieved from a device and the name of that device. The keyboard emulation device must be configured in the configuration of SiteKiosk, including the device name that is used to register the listener. Examples The following example registers a listener for a keyboard emulation device and displays the recieved data.
    <!DOCTYPE html>
    <html lang="en">
    <head>
    	<meta charset="UTF-8">
    	<title>Keyboard Emulation Device Test</title>
    	<script>
    		window.external.InitScriptInterface();

    		var callbackFunc = function (data, devicename) {
    			document.getElementById("text").innerHTML =
    			"Data received from device with the name: "
    			+ devicename + ". Data: " + data;
    		};

    		function registerDevice() {
    			var deviceName = document.
    			getElementById("devicename").value;

    			if(deviceName == "")
    				return document.
    				getElementById("foundDevice").
    				innerHTML = "The device name is empty!";

    			SiteKiosk.RootApp.
    			registerForDeviceData(deviceName, callbackFunc);

    			return document.getElementById("foundDevice").
    			innerHTML = "Registered device: " + deviceName;
    		}
    	</script>
    </head>
    	<body>
    		<h1>Test page for reading the input of keyboard
    		emulation devices configured in the configuration
    		of SiteKiosk</h1>
    		<div>
    			Listen to input from this device that has been
    			configured in SiteKiosk:
    			<input id="devicename" tpye="text" />
    			(state the device name)
    			<button onclick="registerDevice()">
    			Register the listener</button>
    		</div>
    		<span id="foundDevice"></span>
    		<div>
    			Data that has been received:
    			<span id="text">Waiting for data...</span>
    		</div>
    	</body>
    </html>
Applies to SiteKiosk v9.0 (and later versions). Back to top