Sunday, October 31, 2010

ScannerKeystrokeObserver

A class to automatically detect entries from a hardware device that generates keystrokes (like a barcode scanner).

Demo

This class is designed on the assumption that your barcode scanner hardware will act like a keyboard. As a barcode is scanned a series of keypress events will be generated by the device. If these key events are in fast enough succession (the order of milliseconds), then it can be assumed that a scanner device pushed the series of key events. Otherwise it is just normal human input and will be ignored by the barcode reader class.

How to use

Include the following code in the head of your web page.

 <script src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js" language="JavaScript" type="text/javascript" ></script>
<script src="ScannerKeystrokeObserver.js" ></script>
<script>
new ScannerKeystrokeObserver({
onRead: function(v) {
$('txtGlobal').set('value', v).highlight();
}
});
</script>

Get It

No comments: