(I ... think that's the right template)
Line 1: Line 1:
{{Wiki Standards|Not enough information, improper grammar, too confusing}}
+
{{Wiki Standards|Not enough information}}
 
[[Category:Scripting Tutorials|Key Tapping Sensor]]
 
[[Category:Scripting Tutorials|Key Tapping Sensor]]
 
Without much work, when you hold a button, it can do things the button was set to do for a repeated amount of times. However, if you want to make the button be not held, but only pressed once at a time, you can use the scripting in this tutorial.
 
Without much work, when you hold a button, it can do things the button was set to do for a repeated amount of times. However, if you want to make the button be not held, but only pressed once at a time, you can use the scripting in this tutorial.
Line 27: Line 27:
  
 
===Non-Holding Script===
 
===Non-Holding Script===
This is the non-holding-allowed script, which you want to use.
+
This is the non-holding-allowed script, which you will want to use.
 
<scratchblocks>
 
<scratchblocks>
 
when flag clicked
 
when flag clicked
Line 36: Line 36:
 
end
 
end
 
</scratchblocks>
 
</scratchblocks>
this will make it begin to sense the next key action after the key is released, which means you press the key and the backdrop will switch, then you need to release it before press it again to switch to next backdrop.
+
This will make it begin to sense the next key action after the key is released, which means you press the key and the backdrop will switch, then you need to release it and press it again to switch to next backdrop.
if you change the blocks order to:
+
If you change the blocks order to:
 
<scratchblocks>
 
<scratchblocks>
 
when flag clicked
 
when flag clicked
Line 47: Line 47:
  
 
</scratchblocks>
 
</scratchblocks>
If you use this code, you have to press the key, and the backdrop will NOT change until you release it.
+
If you use this code, you have to press the key, and the backdrop will not change until you release it.
  
 
== Uses ==
 
== Uses ==
 
A key tapping sensor could be useful for many things, such as announcement projects, or projects with only words. It's often important in these projects, that users don't skip through the information quickly,  so this script could be useful.
 
A key tapping sensor could be useful for many things, such as announcement projects, or projects with only words. It's often important in these projects, that users don't skip through the information quickly,  so this script could be useful.
 
If one wants to create a [[platformer]], the first code could be used to to create nice, smooth controls.
 
If one wants to create a [[platformer]], the first code could be used to to create nice, smooth controls.

Revision as of 15:58, 21 February 2016

Document stub.png This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. (Date?)
Reason: Not enough information

Without much work, when you hold a button, it can do things the button was set to do for a repeated amount of times. However, if you want to make the button be not held, but only pressed once at a time, you can use the scripting in this tutorial.

What To Do

Holding Script

This is the holding allowed script, which you want to avoid:

when flag clicked
forever
if <key [...] pressed?>
next backdrop
end
end

If you use this one, you might go forward more than one backdrop before you release the key. But you can also use this one:

when key [...] pressed
next backdrop

that will make it better because there will be a tiny pause after a heading block.

when key [...] pressed

(That's also why you don't want to use it in a platformer)

Non-Holding Script

This is the non-holding-allowed script, which you will want to use.

when flag clicked
forever
wait until <key [...] pressed>
next backdrop
wait until <not <key [...] pressed?>>
end

This will make it begin to sense the next key action after the key is released, which means you press the key and the backdrop will switch, then you need to release it and press it again to switch to next backdrop. If you change the blocks order to:

when flag clicked
forever
wait until <key [...] pressed?>
wait until <not <key [...] pressed?>>
next backdrop


If you use this code, you have to press the key, and the backdrop will not change until you release it.

Uses

A key tapping sensor could be useful for many things, such as announcement projects, or projects with only words. It's often important in these projects, that users don't skip through the information quickly, so this script could be useful. If one wants to create a platformer, the first code could be used to to create nice, smooth controls.