Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
I need a fast and reliable way to do key debouncing (basically if I press and hold a key, it only does one keypress until I release it and press it again)
what I have right now is super janky and I'm pretty sure it is the root cause of my problems with the program not always recognizing keypresses:

    debounce = 0;

Then whenever I have something that needs to detect keys, an example of the if statement is

if(kb_ScanGroup(kb_group_7) == kb_Down && debounce == 0)
    debounce = 1;
    [other code]

I really need a better way to do this because if my hunch is correct this is not the way to go.
According to the examples in the toolchain; this is the proper way to read from the keypad:

kb_Data[kb_group_7] == kb_Down

If you want to just detect one single keypress; just do this:

    key_g7 = kb_Data[kb_group_7];

    if (key_g7 == kb_Down && !debounce) {

    if (key_g7) {
        debounce = true;
    } else {
        debounce = false;
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum