I have a cheap magnetic card reader that acts like a keyboard. I connect it and swipe a card, and it types all the card data into the computer. But for some reason, it doesn't work in Java. It does work in everything non-Java I have tried.
What is on the card (actually swiped card in SO editor):
;00548757802?
When using Java:
;0◘)P87┼7\02?
_005487578D♥
;005487G802?
_005*J657802{
♣00548I5♣802?
;≥T548757♠╢·?
≥T54875I↑:?
As you can see, it's different every time. However, the reader sends a newline after the data, which Java does appear to recognize.
My code for reading input:
// Bound to a JTextField
public void keyTyped(KeyEvent e) {
System.out.print(e.getKeyChar());
}
The JTextField also shows the text garbled.
What is wrong here, and how can I fix it?