Skip to content

Instantly share code, notes, and snippets.

@jeffutter
Last active September 4, 2015 09:34
Show Gist options
  • Save jeffutter/511a372470471fd72d1e to your computer and use it in GitHub Desktop.
Save jeffutter/511a372470471fd72d1e to your computer and use it in GitHub Desktop.
Simulate Magnetic Credit Card Swipe (only works in Firefox)
"%B4000000000000002^CardUser/John^030510100000019301000000877000000?;4000000000000002=0305101193010877?".split('').forEach(function(k){
var e = new KeyboardEvent("keydown", {key: k, char: k, charCode: k.charCodeAt(0), keyCode: k.charCodeAt(0), which: k.charCodeAt(0)});
window.dispatchEvent(e);
});
var ev = document.createEvent('KeyboardEvent');; ev.initKeyEvent(
'keydown', true, true, window, false, false, false, false, 13, 0);
document.body.dispatchEvent(ev);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment