Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Dan Baker
  Where is Dan Baker?
 Effort of the Poconos
 Pennsylvania - United States
 Dan Baker
Subject: KeyPress Trap Demo Class
Thread ID: 416169 Message ID: 416169 # Views: 73 # Ratings: 4
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Monday, December 22, 2014 11:39:24 PM         


Version 2 (12/23/2014) includes major improvements:

a. Moved almost all the code into a Custom Timer.
b. Only traps and processes the few letters used in the KeyTraps you want, so
there is no detectable delay for all other keys.

Cheers, Dan B.

Download SCX: KeyTrap Class 54 KB

* * * *

Version 1 Post. . .

I have posted this KeyTrap class just after Jun introduced his new xBox textbox class.
And I think it may complement what Jun has done.  

Who could operate their PC without the handy mouse?  The mouse is immensely useful.
And yet, in tasks where the user wants to keep his hands on the keyboard, the mouse
can put a drag on productivity.

This is where the KeyTrap class comes to the rescue.  I have been using a variation
of it of for over a year in an audio transcription class I made.  And it's allowed me to
transcribe audio files into text — including pausing/restarting/rewinding the audio —
without ever having to take my hands off the keyboard (to use the mouse).

Now to give you an idea how useful this is, professional audio transcribers often use a
foot pedal to perform the same action.

What this class does is reserve two keys (pressed successively) to drive some user
action.  For my audio transcription program they are these keys:

*  jj = Pause or Restart the audio
*  jk = Restart the audio 3 seconds earlier
*  jl = Restart the audio 10 seconds earlier

The class allows you to trap any two keys you want, but the nice thing about using
this combination of keys is:

* The righthand fingers rest comfortably on the J, K, and L keys 
* There are almost no English words that use those combination of characters.

The class can be used in any Textbox or Editbox, so test it out on the leftside Editbox.
Then think about the possibilities.

Say you have a Search Text box.  Well, as soon as you finish typing your search words,
you could type "jj" and launch the search without forcing the user to hit the ENTER key or use a mouse.

Once you get the hang of it, it can be quite convenient.  I've set this up to allow
3 different KeyActions.  Each Editbox or Textbox can have its own unique KeyActions.

Dan B.


KeyPress Trap Demo Class Posted by Dan Baker @ 12/22/2014 11:39:24 PM