A pure JavaScript library to enable the use of card scanners that simulates keyboard input on websites
Switch branches/tags
Nothing to show
Clone or download
Latest commit 6e4b4d9 Mar 17, 2016
Failed to load latest commit information.
dist Converted to pure JavaScript Mar 13, 2016
src Changed wording in comment Mar 13, 2016
LICENSE Converted to pure JavaScript Mar 13, 2016
README.md Update README.md Mar 17, 2016


JavaScript Card Scanner

This library allows you to use hardware card scanners that simulate keyboard input on your websites.

There are no advanced features, so you don't have to worry about over complicating things.


To get started, you need to know how your card scanner returns data, as in what is the suffix and prefix that it puts around the data read from the card.

This information is important, if you're not sure, try running a sample card with a notepad window open, or read the documentation for your specific card reader.

Once you know this, you can initialize the card scanner monitor script this way:

window.CardScannerMonitor({prefix: 'your-prefix-here', suffix: 'your-suffix-here'}, function(data){
	// Perform what you need to with the data here

The function takes two parameters, the first one is an object with the prefix and suffix as elements of the object.

If no suffix is defined, then the Enter key will be used as a suffix.

The second is a function, this function gets performed when the script has read the suffix (all data has been entered). This function should have one parameter, which represents the data read from the card, without the suffix and prefix attached.


View a CodePen Example

Use 'abc' as your prefix, and ';' as your suffix on the demo.


Distributed under the MIT License.