Key capture question.

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Key capture question.

Post by Paul D » Thu Aug 13, 2009 8:11 pm

Is it possible to capture a keystroke if the stack is not active? Basically a user wants to be able to hit shift(or control or whatever)+(any function key) to be able to jump right to another card or stack without having to use the mouse to bring the stack active first. I saw backdrop but it only has mouse support and covers the whole screen anyway.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Thu Aug 13, 2009 8:38 pm

You can use a backscript to capture the keystrokes even if another window has focus - as long as Revolution is the active application.
Drop a button onto your stack, set its name to "MyBackscript" and set its script to:

Code: Select all

on functionKey pFunctionKey
  if the shiftKey is "down" and pFunctionKey = 1 then
    answer "You pressed Shift-F1!"
  end if
end functionKey
Now you can make this button a backscript with

Code: Select all

insert the script of button "MyBackscript" into back
And now hitting F1 while holding down the shift-key will pop up the answer dialog box. You can hide the button so no one sees it, and it will still work.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Thu Aug 13, 2009 9:12 pm

Wouldnt the current window that has focus be the active application? I dont think Im following... :?

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Fri Aug 14, 2009 5:13 am

Hmm, perhaps I was thinking too Mac/multi-window oriented, rather than asking about your application design. My solution would work if it was another window of the same application, that held the focus.
If what you're asking for is a way to trap these events even when your application is buried in the background and the user is in, say, Microsoft Word, then I'll have to disappoint you: Revolution cannot intercept these events at the system level.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

sims
Posts: 43
Joined: Wed Apr 12, 2006 5:36 pm

Re: Key capture question.

Post by sims » Fri Aug 14, 2009 8:05 am

Paul D wrote:Is it possible to capture a keystroke if the stack is not active? Basically a user wants to be able to hit shift(or control or whatever)+(any function key) to be able to jump right to another card or stack without having to use the mouse to bring the stack active first. I saw backdrop but it only has mouse support and covers the whole screen anyway.
You need an external for that, one for each OS really. A project I built http://www.einspine.com doesn't record the keys but merely uses this to keep track of the number of times the user presses keys or clicks the mouse in order to measure RSI potential. It also gauges if the user might be clutching the mouse and not using it (tracks pixel movement). The app of course, needs to be running but does not need to be frontmost.

Be prepared to keep remaking those externals as OS's change also. Not trivial.

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Fri Aug 14, 2009 1:08 pm

Ok, sounds good. I didnt think it was possible but figured I would ask. 8)

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Post by shadowslash » Sat Aug 15, 2009 10:01 am

Hi Paul D,

I'm not sure if I would be much of a help but check this out and tell me if it does the thing that you want to achieve. Image

KeyTracker.rev
Image
Parañaque, Philippines
Image
Image

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Tue Aug 18, 2009 1:21 pm

Yep this is perfect. Thanks Shadows!

Post Reply