Detect whether a key is being held before script execution?

T

Thomas Wilson

Hi All!

I am looking for a way to have a script detect whether or not a key is
pressed and held down before it runs.

Basically, I want the script to execute one way if the key is pressed
and another if it is not pressed.

I plan on having the script launched automatically at startup and will
need to have the key pressed before it runs.

Can anybody point me in the right direction to achieve this?

Thanks in advance!

WPPK
 
A

andrew mcelroy

Hi All!

I am looking for a way to have a script detect whether or not a key is
pressed and held down before it runs.
Is this within the context of a web browser, command line interface,
or gui (like windows start up)?

Your best bet is to automatically launch your first script which will
watch for user input, then conditionally launch the next part.
Without more info, I am not entirely sure what you are trying to accomplish.


Andrew McElroy
 
T

Thomas Wilson

Command Line. I want to have the script launched at startup, by having a
Terminal command call the script, then when the script executes, it
determines whether or not the key is being held down and if it is, it
then modifies the permissions of certain folders on my hard disk.

I am using OSX.
 
T

Thomas Wilson

Could anybody possibly give me a code example of how to detect a
keyboard event?
I am new to Ruby and I am not quite familiar with the syntax yet.
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top