Blocking a key for most uses
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Blocking a key for most uses
I'm writing an application where there are effectively two tasks going on. One task involves writing answers to questions in various boxes. At the same time another task involves listening to numbers being read out and pressing a key when 3 odd numbers are heard in a row.
My question is can I block out one key so that it ONLY, say, puts a 1 in a variable and does nothing else? What I'm aiming for here is a key that doesn't interfere with the person's responding to the questions when they press it. For instance if it were the space bar I was to use, I wouldn't want lots of random spaces being inserted into their answers.
My question is can I block out one key so that it ONLY, say, puts a 1 in a variable and does nothing else? What I'm aiming for here is a key that doesn't interfere with the person's responding to the questions when they press it. For instance if it were the space bar I was to use, I wouldn't want lots of random spaces being inserted into their answers.
Dear gjn1w07,
How doesn't this answer your question?
http://forums.runrev.com/phpBB2/viewtop ... ight=#6331
Best regards,
Mark
How doesn't this answer your question?
http://forums.runrev.com/phpBB2/viewtop ... ight=#6331
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
That was a slightly different question, hence the seperate thread. That did answer my original question, which was just "how do I use the space bar in the code"
This question is how do I for instance, have the "g" key ONLY put 1 into the variable tGPressed, and not pass the fact that it has been pressed to any other field? So for instance if the user was in a text entry box typing in the word "hello" and pressed the g key in the middle of typing, I want the g key press to put 1 into the variable tGPressed without actually typing a g. So if a user pressed g in the middle of typing hello, it ends up as "hello" and not "helglo". In effect I want to disable the key for all but one use for the card.
This question is how do I for instance, have the "g" key ONLY put 1 into the variable tGPressed, and not pass the fact that it has been pressed to any other field? So for instance if the user was in a text entry box typing in the word "hello" and pressed the g key in the middle of typing, I want the g key press to put 1 into the variable tGPressed without actually typing a g. So if a user pressed g in the middle of typing hello, it ends up as "hello" and not "helglo". In effect I want to disable the key for all but one use for the card.
Dear gjn1w07,
The script is still the same as in the other thread:
If you want to take several different keys into account, just add some if-then statements:
Make sure to put any characters in quotes.
Kindest regards,
Mark
The script is still the same as in the other thread:
Code: Select all
on keyUp theKey
if theKey = <some character> then
--do stuff here
end if
end keyUp
Code: Select all
on keyUp theKey
if theKey = <some character> then
--do stuff here
if theKey = <some other character> then
--do other stuff here
else
pass keyUp
end if
end keyUp
Kindest regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Garrett,
If you know that you want to "catch" a specific character, the space bar or e.g. a question mark, keyUp and keyDown are sufficient. RawKeyUp and rawKeyDown are slightly more complex and useful if you want a script to respond to the backspace key, the delete key, escape key, et cetera. Nonetheless it is possible to use rawKeyUp instead of rawKeyDown if you need to.
Btw, BvG is right about keyDown, of course, if you don't want the "g" to be put into the field you're typing in. I wonder how one would write "good morning" though ;-)
Best,
Mark
If you know that you want to "catch" a specific character, the space bar or e.g. a question mark, keyUp and keyDown are sufficient. RawKeyUp and rawKeyDown are slightly more complex and useful if you want a script to respond to the backspace key, the delete key, escape key, et cetera. Nonetheless it is possible to use rawKeyUp instead of rawKeyDown if you need to.
Btw, BvG is right about keyDown, of course, if you don't want the "g" to be put into the field you're typing in. I wonder how one would write "good morning" though ;-)
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
They work differently. The rawKey messages use numbers, the same ones as the keysdown() function. The key messages use the chars themselves.
This means that all characters that can't be typed into the script editor as a string, will not be usable with the key messages. A good example is the return key, you can't just type that into a string in the script editor, therefore it only works with the rawKey messages.
This means that all characters that can't be typed into the script editor as a string, will not be usable with the key messages. A good example is the return key, you can't just type that into a string in the script editor, therefore it only works with the rawKey messages.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode