Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detect when input box filled by keyboard and when by barcode scanner

    Hi exeperts,


    How I can programmatically detect when text input filled by typing on keyboard and when it filled automatically by bar-code scanner?


    And I want to restrict users to enter barcode manually in text box and allow from scanner.


    Regards,
    Bikshapathi.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,489
    Thanks
    205
    Thanked 2,579 Times in 2,557 Posts
    onkeypress

    I don't understand "And I want to restrict users to enter barcode manually in text box and allow from scanner." Are you saying you want only certain characters (digits or whatever) to be entered at the keyboard?

    In HTML5 you can use
    Quantity (between 1 and 5): <input type="number" name="quantity" min="1" max="5">



    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Last edited by Philip M; 08-26-2014 at 07:48 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Philip,

    Thanks for your reply.

    I want to restrict everything from user not specific characters. If I restrict with keypress event , It is restricting scanner as well. I could not differentiate the scanner and manual input from keyboard.


    Regards,
    Bikshu.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,489
    Thanks
    205
    Thanked 2,579 Times in 2,557 Posts
    Quote Originally Posted by bikshu2313 View Post
    Hi Philip,

    Thanks for your reply.

    I want to restrict everything from user not specific characters. If I restrict with keypress event , It is restricting scanner as well. I could not differentiate the scanner and manual input from keyboard.

    Regards,
    I still don't understand what you mean by "restrict" (which is not the same as block or prevent) but if input from a scanner triggers an onkeypress, then there is no way to distinguish between the two.

    One possible solution would be if the keyboard and barcode reader wand are connected to different computer ports (one may be usb,
    one may be serial or a PS/2 connector) then the fact that data is received on different ports may be one way to solve your issue.
    Last edited by Philip M; 08-26-2014 at 03:44 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    29,221
    Thanks
    83
    Thanked 4,885 Times in 4,846 Posts
    I think onkeypress is a possible key to a way.

    Suppose you noted how long it is between key presses. A human will surely take a quarter of a second or more between key presses. The scanner will most likely take only a few milliseconds between events.

    Is that a perfect solution? No, not at all. If a given <form> field only needs a single character to be filled in, then there won't be multiple key presses to do the timing on.

    But I think this may be worth playing with--see if it helps at all.
    Be yourself. No one else is as qualified.

  • #6
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,541
    Thanks
    11
    Thanked 608 Times in 588 Posts
    i to would work on a time-based solution. the barcode wands i set up years ago dumped in 20cps, way more than a human can do, even on a ten key. start a timer on first keydown, stop the timer after 500ms of no activity; if length>8 and time < 600ms, you got a robot typer. you might have to adjust the numbers a bit, but that pattern is likely your best bet, given that key events don't contain any details on which specific device triggered the event.
    Last edited by rnd me; 08-27-2014 at 10:58 PM.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #7
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,137
    Thanks
    11
    Thanked 102 Times in 100 Posts
    with better scanners (i.e. not the cheap cheap ones) you can program them to add a prefix and/or a suffix, then you can search for that string and remove it from the input
    ... of course if someone knows the prefix/suffix they can just type it in as well~
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,489
    Thanks
    205
    Thanked 2,579 Times in 2,557 Posts
    Quote Originally Posted by firepages View Post
    with better scanners (i.e. not the cheap cheap ones) you can program them to add a prefix and/or a suffix, then you can search for that string and remove it from the input
    ... of course if someone knows the prefix/suffix they can just type it in as well~
    Yes, but he is trying to block typing, not the scanner!

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #9
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,137
    Thanks
    11
    Thanked 102 Times in 100 Posts
    Quote Originally Posted by Philip M View Post
    Yes, but he is trying to block typing, not the scanner!
    understood... that said, if you programmed the scanner to use a special char as the prefix then you could test for that onkeyup ? best I can manage anyway.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    29,221
    Thanks
    83
    Thanked 4,885 Times in 4,846 Posts
    Makes sense to me, Firepages. If you don't detect the prefix as the first character found via onkeyup you can reject the rest of the onkeyup's (at least for some period of time...to give them time to connect the scanner).
    Be yourself. No one else is as qualified.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •