Detect quickest keypress (gameshow buzzers)

Posted on 2012-08-14
Last Modified: 2012-08-20

I've got hardware for presenting gameshow buzzers as keyboard input. For testing/writing I'm just using my keyboard to do the sme thing.

I need to determine which contestant buzzed first, which is easy enough using a keypress or keydown event on a textbox for example. (I got a bool vBuzzed which starts false, and the first keypress sets it to true before doing the rest of my code.

However, if 2 buttons are pressed simultaneously, it is ignoring both of them completely. Even if I remove the key events and just watch the textbox, test doesn't appear, which defies the issue of determining quickest buzzer...

Is there a way I can make the app see (and thus detect) these simultaneous presses?

Question by:howartp
    LVL 16

    Expert Comment

    I'm not able to test with VB.Net at this very moment, but in every windows application I attempt to utilize, it never tosses two keys pressed simultaniously.  Both keys always register.

    Is there some way that your logic could be tossing both key events away?  Specifically, what is your code doing in the key events?  

    Without the ability to do additional testing at this moment, about the only thing that comes to mind is that you are setting vBuzzed to true on the 1st key event and ignoring all key events when vBuzzed is true.  In that situation, I could see where it would be possible for the operating system to do something unexpected to confuse your logic.  For example, it might first send a NULL key event (because two keys were pressed simultaniously) followed by two more events, one for each of the two keys... or the events might execute simultaniously, and you have the equivilent of a multi-threaded race condition (i.e. both events execute set the vBuzzed flag, then both read the vBuzzed flag and ignore itself).  

    Without seeing a specific code example, I'm just shooting in the dark here.

    If you are indeed attempting to "deactivate" key events with the 1st key pressed, I would instead suggest that the key events append the key to a Form level string... then simply look at which key comes before the other in the string.

    Author Comment


        Private Sub tbBuzzers_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles tbBuzzers.KeyPress
            If (Not vBuzzed) And ((e.KeyChar = "0") Or (e.KeyChar = "1") Or (e.KeyChar = "2")) Then
                vBuzzed = True
                If e.KeyChar = "0" Then
                ElseIf e.KeyChar = "1" Then
                ElseIf e.KeyChar = "2" Then
                End If
                e.Handled = True
            End If
        End Sub

    Open in new window

    This is the original code I had in, which is what I have used in a similar circumstance for another gameshow about 5 years ago.

    Does it look ok?

    I am half-remembering that I had a similar issue when initially programming it back then, which would have been away from home on a laptop, but when I got back home I've a feeling the issue disappeared - so I'm wondering if the laptop is blocking simultaneous keys at hardware/driver level before they even get to Windows...

    If the code looks ok, I'll wait till I get home at the weekend and check the same code on my PC.


    [Edit:  Copied wrong copy of the sub-routine]

    Accepted Solution

    In fact, I've just realised that it's my Kensington USB Keyboard which is surpressing the multiple keypresses - if I press them directly on the laptop's keyboard then they work as intended.

    So, apologies for wasting your time.


    Author Closing Comment

    In fact, I've just realised that it's my Kensington USB Keyboard which is surpressing the multiple keypresses - if I press them directly on the laptop's keyboard then they work as intended.

    So, apologies for wasting your time.


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now