Capture keyboard input

I have a swing app that will run on a touch screen. There will be no keyboard. I will have a magnetic card reader plugged into the ps/2 port.
Basically I need to capture the output of the magnetic card reader. At the moment when a card is swiped it goes in the first JTextfield.
Now I can capture the output outside of swing by using
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String data = stdin.readLine();
System.out.println(m_data);
However this does not work inside of swing or at least my swing app.
So in swing, how can I capture or redirect text input?
I guess I could write a fuction that appends a character each time a key event occurs like KeyTyped. However I am not sure that is the most efficient way to go about it.

A document listner might work, however I think that url you posted also shows a way using an action listner.
Something I forgot to mention was, when I swipe the card I do not want the card's data placed in a JTextField.
To the point when a card is swiped I want the data in a string.
At the moment when I swipe a card it goes into a JTextfield. I do not want that to be the case. Sure I can make a way around it with a hidden text field or something, and use a listner for events on the text field.
However I do not think that is the proper way to go about this.
So I am looking for an event that will be fired or take place as soon as there is input from the keyboard/card reader. I do not want a JTextField to even have the chance to grab and display that data. I want to know first, and take that data and do something else with it.
In detail, when a card is swipped, the data will be parsed and JTextFields will display the parsed information. However I need to be the first one receiving the data, not any of the JTextFields in my app.
The app does not require use of a keyboard. If possible I would like the app to not work at all with a keyboard, and any input from a keyboard or card reader is calling my own code to deal with those events.
So if someone does plug in a keyboard, I do not want them to be able to do anything. That's not a must, but if I can accomplish it with the above I will be a happy camper.
In short I need to capture all input from the ps/2 port, and be notified with input starts and ends. Or at least when it ends.
Any suggestions are greatly appreciated.

Similar Messages

  • Capturing keyboard input as written

    I would like to know if I can use Scanner class to make a program to read users input on the keyoard same way like talk or ytalk program on unix does? Meaning, I would like to read each character immediately and not wait for carriage return.
    Then I would like to write each character somewhere. Perhaps first just echo it on the command line.
    Thanks for any ideas with the Scanner class (JDK 1.5)!
    Jukka

    Hey,
    I don't want to believe Peter's answer. Hard to
    believe that I cannot read from the console
    "on-the-fly".
    JukkaWell life is full of things I don't want to believe, but life sucks don't it.

  • Just started with NetBeans IDE, need to capture all keyboard input!

    Hello,
    I discovered that I can only capture keyboard events when my GUI application has focus. Ok, but I need a functionality that can capture all keyboard input, even if my application runs in the background or in the system tray.
    How can I achieve that?
    Regards,
    Mirza

    I know...sorry, didn't mean to imply otherwise.Don't worry about it; I wasn't offended. (I didn't think that that was what you were tying to do.) I was trying to (subtly) take this a different direction. (Was going to write something Solaris specific or perhaps something in ASM that would effectively do what the O/P wanted. Seeing as how Key Loggers only serve one practical purpose - as far as I know - I just wanted to give him code that he could do nothing with.)

  • Take printscreen and detect mouse/keyboard input

    hi guys,
    I'm looking a way to take printsceen and detecting mouse/keyboard input in Adobe Air app using html/ajax .. is it possible ?
    any ideas ..please

    I wrote a blog post on how to do screen capturing using Adobe AIR abnd HTML/JavaScript. Maybe it'll help you out:
    http://www.andymatthews.net/read/2009/11/05/Capture-BitmapData-with-JavaScript-AIR-applica tions
    As for detecting key input, you can add a keydown/keydown event to the document quite easily.
    document.addEventListener('keydown', function(evt){
         // do something

  • Keyboard input delay Flex/AIR

    I've build an AIR desktop app that uses an USB barcode scanner. To capture the token provided by the barcode scanner an input field is used.
    When testing the barcode input was only partially captured by the scanner. This was caused by the barcode scanner's input coming in the fast. Increasing the key stroke delay of the barcode scanner (config tool from motorola) solved the problem however this is not ideal.
    Does anyone has experience with this type of problems? What is an approach to solve this? Maybe by writing an Java compagnion app that captures the keyboard input?

    I just ran into this same problem. Our users are scanning barcodes from various labels using various types of scanners (changing the delay using scanner software wasn't an option). We also have to allow them to scan to a TextInput within a DataGrid, which created even more problems. There were 2 very interesting things I learned in coming up with a solution for this one:
    1. As mentioned previously, the scanner inputs the data so quickly that the enter key event is often processed before the change event for the text. I tried several solutions (like trying to force the change event before the enter key is processed), but learned that the best solution was just to add the delay as mentioned in previous posts.
    2. When adding to a DataGrid control, I learned that both the DataGrid's & the TextInput's key down events are fired by the same SystemManager event. Though you can override the TextInput's keyDownHandler, you can't override the DataGrid's because it's a private method. So, even though my delay was being processed in the TextInput, the DataGrid was forcing control away from it and moving to the next item in the grid. To get around this one, I had to stop propagation of the event from the TextInput, then re-start the DataGrid's event once the delay was complete. I also had to process a focus-out event to get it to move to the next item in the DataGrid.
    Here's the code I used inside a custom TextInput control to handle processing both stand-alone and inside a DataGrid:
    override protected function keyDownHandler(event:KeyboardEvent):void
          // If the enter key was pressed, then we need to add a delay.
          // Barcode scanners quite often process the enter key before the TextInput
          // control has time to finish processing all the text. (e.g., Instead of
          // getting 12345 as a text entry, you could get 123 or 1234.)
          if (event.charCode == Keyboard.ENTER)
               // If this is the first time we've processed the enter key, we need to
               // add the delay.
               if (_keyboardEvent == null)
               _keyboardEvent = new KeyboardEvent(event.type, event.bubbles,
               event.cancelable, event.charCode, event.keyCode, event.keyLocation,
               event.ctrlKey, event.altKey, event.shiftKey);
               event.stopImmediatePropagation();
               barcodeTimer(_keyboardEvent);
                          return;
               // If the enter key is pressed while we are still in the delay, ignore
               // it.
               else if (_keyboardEvent != null && _keyboardEvent != event)
                         return;
               // If the delay is complete, then we need to restart events related to
               // the enter key so the control is handled properly.
               else
                    super.keyDownHandler(event);
                    // If the TextInput is inside a DataGrid, then we need to dispatch the
                    // DataGrid's key down event. We also need to make sure the proper
                    // focus change happens (since this was stopped in the original event
                    // propagation).
                    if (parent != null && parent.parent != null &&
               parent.parent is mx.controls.DataGrid)
               parent.parent.dispatchEvent(event);
               dispatchEvent(new FocusEvent(FocusEvent.KEY_FOCUS_CHANGE, true,
                              false, null, event.shiftKey, Keyboard.TAB));
            _keyboardEvent = null;
                    return;
          super.keyDownHandler(event);
    * This is a copy of the keyboard event to be processed once the barcode
    * delay is complete.
    private var _keyboardEvent:KeyboardEvent = null;
    * This method launches a timer of sufficient length to allow barcode
    * scanner text to be processed before it re-launches the keyboard event.
    * @param event This is the key-down event to be restarted once the timer is
    * complete.
    private function barcodeTimer(event:KeyboardEvent):void
          var t:Timer = new Timer(30, 1); // 30 ms
       t.addEventListener(TimerEvent.TIMER,
               function():void
               keyDownHandler(event);
       t.start();

  • Is there a way of using keyboard input?

    Is there a way of using keyboard input in Edge? For example when you press the space-bar it will open a url. This is probaly done though programing.

    Shift/Command and Alt/Control have there own separate event routines.
    Example
    e.metaKey         // depends on browser and targets the Apple key
    e.ctrlKey             // targets the Control or Ctrl key
    e.altKey              // targets the Alt key
    e.shiftKey           // targets the Shift key
    So if you only wanted the event to fire when the Shift key is pressed, then
    if (e.shiftKey){                                              //If Shift key is pressed 
           window.open("http://www.adobe.com", "_blank");
    If you wanted to combine the Shift key + Space Bar to trigger the event, then resort to logical operators. In this case you want to 'combine' key strokes, then the logical operator would be a double &&, and demonstrated below.
    if (e.shiftKey && e.which == 32){                     //If Shift Key + Space Bar pressed
          window.open("http://www.adobe.com", "_blank");
    If you wanted to combine the Shift key + some other keyboard Character Code from the above noted list (http://rmhh.co.uk/ascii.html), then change the value of e.which to equal (==) that Character Code. Example from the list, the Character Code for the keyboard 'a' is 65, as altered below.
    if (e.shiftKey && e.which == 65){                     //If Shift Key + A pressed
    window.open("http://www.adobe.com", "_blank");
    To get an accuarte keycode value, there are two demonstrations on this page http://api.jquery.com/event.which/, whereby you can type in thee field and it will capture the value for you.
    Good luck
    Darrell

  • Disable most of keyboard input

    Would it be possible with a pure Java code only to disable normal use of keyboard input (like have the application just eat every keystroke except the ESC key for example)?
    I'm most interested in using this for disabling screen capture key sequences (such as CTRL-Alt-PrtScr in Windows) but also for disabling many other key sequences such as CTRL-Alt-Del.
    Thanks.

    This would be too insecure so it's not possible. Imagine if an applet on a webpage could intercept all your keyboard input and steal all your passwords as you log into sites !

  • Keyboard input, alt + "111" possible?

    keyboard input, alt + "111" possible?

    Hai,
    you should provide some more inputs on your post..
    any way we can detect alt+111 as following
    Use KeyListener for your component...
    KeyPressed(KeyEvent evt) {
    processKey(evt);
    KeyPressed(KeyEvent evt) {
    processKey(evt);
    processKey(evt) {
    if(evt.getKeyCode() == KeyEvent.VK_ALT)
    // do some thing
    if(evt.getKeyChar() == KeyEvent.VK_1)
    // do some thing..
    So we can capture alt+111
    Regards
    Desizners

  • How to capture text input value by user in a LOV search popup page?

    I need to capture the input by the user in LOV search page. I added one controller in the LOV region, and the flow is also working, but what I need to hold the search input in the search popup page. Also do you know what is the id of " Search Term" text input? then I can try to hold the value in PFR of the CO.

    Hi Sandeep,
    Yes, as of now I need to populate blank, so I need to modify the SQL, therefore I need to capture the value which is given by the user. I am trying to capture the value through passive criteria, but not able to get the result. I added below code in PFR of lov region controller,
           Dictionary passiveCriteriaItems = pageContext.getLovCriteriaItems();
           String lov = (String)passiveCriteriaItems.get("SwitchLOV");
          if ((lov != null) && !("".equals(lov)))
               throw new OAException(lov, OAException.INFORMATION); 
    SwitchLOV is a lov map I have added in the LOV, and
    Programmatic Query set to true. and
    LOV Region Item is the id for which user searches.
    I am getting null in the "lov" where i have give some value in the search field.
    Is this would be the way?
    I dont understand where is the issue, Please suggest.

  • TS3280 How can i enable both paired bluetooth and ios keyboard input at the same time?

    How can i enable both paired bluetooth and ios keyboard input at the same time?
    This is needed for the app im working on. Need some user input via keypad as well as scanner input via a paired bluetooth scanner.

    You probably should not be using a keyboard bluetooth profile for a scanner, I am not a developer for apple so do not know the location for you to find out the correct profile you should be using for an input device that is not a keyboard. Sorry,
    I am sure if you navigate the apple developer site you will probaly finmd what you're looking for.
    https://developer.apple.com

  • I have a new mac book pro (sept 2014) and am suddenly stuck on the log-in screen. Keyboard input not working to enter my password. Already tried a basic restart and a cmmnd/ cntrl/ pwr troubleshoot to no effect.

    I have a new mac book pro (sept 2014) and am suddenly stuck on the log-in screen. Keyboard input is not working to enter my password. Seems to be a log in issue as keyboard works for forced troubleshooting. (And b/c when I first noticed the problem, I was able to enter my log in password but then everything sort of froze. Now, no ability to enter the password.) Already tried a basic restart and a cmmnd/ cntrl/ pwr troubleshoot to no effect.

    Reset PRAM:   http://support.apple.com/kb/PH14222
    Start up in Safe Mode.
    http://support.apple.com/kb/ph14204
    A new Mac is in warranty for 1 year from the date of purchase.
    A new Mac comes with 90 days of free tech support from AppleCare.
    AppleCare: 1-800-275-2273
    Call AppleCare or take it to the Apple store to have it checked out.
    Genius Bar reservation
    http://www.apple.com/retail/geniusbar/
    Best.

  • How to have same keyboards input source in Mac and Windows???

    I use Canadian French-CSA on my Mac keyboards input source. Using Windows 7, I can't find the good setting for my keyboards to be the same when I it keys.
    I run Windows over Parallels Desktop
    Can anybody help?
    Thank you

    Can I use an AirPort Extreme Base Station "n"
    Yes.
    and if so, will my MacBook work with this at maximum download / upload speed (i.e. equivalent to the cable)
    The speed of your internal network generally is much much faster than the speed of your internet connection. Unless he has an internet connection faster than approx 6Mbps then even dropping down to the old 802.11b Airport would not seen any decrease in speed of downloads etc...
    and will my brother's PC's also be able to connect?
    If his PC is 802.11b/g-compliant, it shouldn't have any problems connecting to the AirPort base station.
    Or is there another Airport base station?
    The other AirPorts would work, but the AirPort Express & older 802.11g AirPort Extreme base stations have a max. range of 150 feet.
    OR-- should I head down to "Generic Computer Store" and just by a wireless router (WiFi)(think that's what they call them) and connect this to his cable modem? IF SO WILL THAT WORK FOR MY MAC?
    That is always an option as well, especially since he will be the primary user throughout the year. I'd suggest going with a brand name, like Belkin, D-Link, or Linksys for the wireless router choice.

  • How to use the phone's Mini-Keyboard Input with the 'Textbox'(MIDP2.0)?

    (My apology. My English is not perfect but I'll try my best. >_<)
    Hi. I'm trying to create a textbox(in my own little application) that is compatible with the mini-keyboard input feature.
    This problem involved any device that have a built-in "mini-keyboard".
    Problem:
    I tried the 'Textbox' class from MIDP2.0 but the result, as expected, is like using the phones with no built-in keyboard.
    (Forexample if I want to input the character 'C' inthe text box, I need to press number '2' button three times to let it circle through 'A' -> 'B' then 'C'. )
    Then I tried entering URLs in the phone's built-in web browser, the result is I can use the mini keyboard to type like a PC keyboard.
    Question: How do I implement such textbox that is fully compatible with the built-in mini Keyboard?
    I tried browsing through the MIDP2.0 API but it seems the 'Textbox' class there couldn't do it.
    Thank you. =)
    /bow
    Edit/Delete Message

    The textbox should have input just as any other normal phone input. If not, something strange is going on.
    Anyway , there is no use to make your own input method, since every phone has another implementation of this anyway. It would only confuse users.

  • Firefox and Thunderbird are suddenly not accepting keyboard input

    Keyboard shortcuts still work just input in any kind of input field fails so I can still use ctrl+C / CTRL+V to somewhat use firefox and Thunderbird But all input fields are completely unresponsive to keyboard input
    The problem suddenly arose while I was browsing.
    I have the same issue on all program's based on the Gecko engine and I confirmed them so far in Firefox, waterfox, instantbird, thunderbird and fossamail. However chromium / windows / basically everythign n
    To fix it I tried the following:
    Restarting firefox
    Restarting firefox in savemode
    Rebooting
    Changing the keyboard layout in windows
    Using a different keyboard
    Again rebooting
    Pressing F7 to check for caret mode which was disabled
    pressing winkey + F9 (Whatever that does)
    I am running windows 8.1(x64)

    Solved, Changing the keyboard layout again and rebooting fixed it. I tried using the on screen keyboard which worked so I changed the keyboard layout again and rebooted and now it works just fine. I still wonder what caused a Gecko wide issue like this?

  • Default Keyboard input change in using roaming Profile on different Win 7

    We found a strange problem on default Keyboard setting.
    We are using roaming profiles for all users.
    One of our users is using two Windows 7. One Windows 7 is VDI for working out of office and another Win 7 is her local PC.
    She is only using Two keyboard input: Chinese Traditional English and Chinese Traditional Pinyin.
    Whenever she had used the Windows 7 VDI, when she comes back to office and use her local PC, the default Keyboard input will automatically change to Chinese Traditional Pinyin.
    The user said she had not changed any default keyboard input in the VDI of local PC.
    Is there anything we can do for this issue?
    Ivan

    Hi Ivan,
    I am just writing to check the status of this thread. Was the information provided in previous reply
    helpful to you?
    Do you have any further questions or concerns? Please feel free to let us know.
    If you have any feedback on our support, please click
    here
    Karen Hu
    TechNet Community Support

Maybe you are looking for

  • Crystal Report to PDF

    I am trying to send the data from a single record to a Crstal Report that I created and then create a PDF from that report that I can Print.  This is the error message that i get  Exception Details: CrystalDecisions.CrystalReports.Engine.DataSourceEx

  • All-in-One Devices and Acrobat

    I'm looking for recommendations for All-in-One machines that work well with Adobe Acrobat. While online reviews are nice, they rarely get into the kind of detail I need. Here's the horror story. We recently purchased an HP Officejet J4580, because it

  • HT1473 how do i save an audio file from a webpage to iTunes?

    how do i save an audio file from a webpage to iTunes?

  • Trace the reference Standard movement type from customized movement type

    Hi, In my system there are few customized movement type. Can I know which Standard movement type was used as reference to create the customized movement type.

  • Cleaning up JNLP files

    Is there a way to reliably clean up downloaded JNLP files from the desktop or wherever the user has specified downloads are to be placed when the application is done? Leaving a bunch of JNLP files littering the desktop or home directory seems somewha