Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Key Tap Monitor; with Key and Toggle Counter, and Combo Detector

Author
Message
vibe runner
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: The Future
Posted: 4th Jun 2007 14:44 Edited at: 4th Jun 2007 16:59
START:

At start of program call StartKeyTapCheck()

ENGINE FUNCTIONS:

For each key you're interested in monitoring call KeyTapCheck() with the scancode, or KeyTapValueUpdate() which will do the lot. The advantage of KeyTapCheck is it returns if a key has been pressed (not held).

UTILITY FUNCTIONS:

Counters/Toggles:

Call KeyTapValueToggle() for the toggle status of a key, or KeyTapValueCount() for a count of that keys keypresses.

Combos:

It's possible to detect combos, including "combos" of a single key. This is handy for detecting specific keytaps after a KeyTapValueUpdate() has been called.

There are two groups of combo detector functions.

The first is KeyTapCheckCombo(0,0,0,0,0,0)

The 0s are input paramters, between one and six scancodes. It returns 1 if those scancodes are being tapped. The difference between this and other functions is some of the later scancodes of this function can be zero.

There is a keystate variant: KeyScanCheckCombo(), again taking the same format as above including ending paramters can be zero.

The second group are for fixed numbers of scancodes, where each parameter is expected to be filled.

KeyTapCheckCombo1(0)
KeyTapCheckCombo2(0,0)
..
KeyTapCheckCombo6(0,0,0,0,0,0)

There are keystate variants.

KeyScanCheckCombo1(0)
KeyScanCheckCombo2(0,0)
..
KeyScanCheckCombo6(0,0,0,0,0,0)

There are also some handy constant definitions typed out.

The example code clarifies that all, I hope.

Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 4th Jun 2007 15:28
vibe runner,

Amazing how we produce something so similar and yet so different just hours apart

I'll check it out when I get home.

Cheers,

Cloggy
vibe runner
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: The Future
Posted: 4th Jun 2007 15:33
Isn't it? This occupied a good part of my Sunday afternoon.
Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 4th Jun 2007 15:40
Mine took 2-3 hours Sunday night. Two completly different things that are so closely related. spooky!

Cheers,

Cloggy

Login to post a reply

Server time is: 2024-11-22 18:39:32
Your offset time is: 2024-11-22 18:39:32