Discuss Scratch
- Discussion Forums
- » Suggestions
- » Suggestion: Repeat while key pressed, and On Single Key presses.
- NMario84
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
I notice there is only one event for ‘When <rup arrow> key pressed’. However, when creators use this to make a jump command, they always end up with the Bunny Hop mechanic (AKA jumping forever), which feels so unnatural. Maybe have 2 separate event tags?
1.'On <space> key pressed''..
2.“when <space> key held down”
The difference being for the first one, holding space key forever, the event action will only happen just ONCE.
The second option, the event action will ALWAYS happen when the key is held down.
Also, there is no option for ‘ENTER’ key….. WHY? The is only option for arrow keys, alphabet, and numbers. Not even a Shift Key, or a Ctrl Key, a + key, or a - key. Maybe include more keyboard functions?
1.'On <space> key pressed''..
2.“when <space> key held down”
The difference being for the first one, holding space key forever, the event action will only happen just ONCE.
The second option, the event action will ALWAYS happen when the key is held down.
Also, there is no option for ‘ENTER’ key….. WHY? The is only option for arrow keys, alphabet, and numbers. Not even a Shift Key, or a Ctrl Key, a + key, or a - key. Maybe include more keyboard functions?
- ScolderCreations
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
I feel like there are workarounds to achieve these things.
- NMario84
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
Yea I am sure there are, but it would be easier if we had a fix like such so we can determine the factor easier.
- ScolderCreations
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
Maybe make a variable that keeps track of how long a button has been pressed?
- -Accio-
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
To achieve the functionality you are asking for in the first block, you can do this:
The second suggestion you have listed for more key support is a duplicate of this one.
Nevermind, that topic is closed as a duplicate, but the duplicate that was linked was deleted.
when [space v] key pressedThe “when <space> key held down” would act the same as the current functionality of the when key pressed block if I am understanding you correctly.
change [example v] by (1)
wait until <not <key [space v] pressed?>>
The second suggestion you have listed for more key support is a duplicate of this one.
Nevermind, that topic is closed as a duplicate, but the duplicate that was linked was deleted.
Last edited by -Accio- (June 29, 2021 19:37:59)
Hi There! I'm -Accio-
I am currently attending university for a Bachelor's of Science in Chemistry.
“If you are not part of the solution, you are part of the precipitate”
- the2000
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
You can check for non-repeating press events like this:
Anyway, the “activate once on key press” hat seems like a nice idea (I always thought the implementation of the key pressed hat was a little weird), but I'm not sure about the other idea. Seems a little too easy to work around to me.
when green flag clicked“Repeat when key pressed” can be worked around through a similar script:
forever
wait until <key [... v] pressed?>
...
wait until <not<key [... v] pressed?>>
end
when green flag clicked…Or, if you're feeling fancy and you want to use the sketchy hidden blocks to save space, you can do this:
forever
repeat until <not<key [... v] pressed?>>
...
end
when green flag clicked
forever
while <key [... v] pressed?> {
...
} :: control
Anyway, the “activate once on key press” hat seems like a nice idea (I always thought the implementation of the key pressed hat was a little weird), but I'm not sure about the other idea. Seems a little too easy to work around to me.
- NMario84
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
Actually, I think the If statement blocks can be some help with this as well. But I'll see what I can do.
I wish I could save these codes posted on boards for reference. I suppose the Print Screen button and paste in to image editor would do that?
I wish I could save these codes posted on boards for reference. I suppose the Print Screen button and paste in to image editor would do that?
- ScolderCreations
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
You could screenshot and crop
- the2000
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
You could recreate them in the editor once, and then save them to your account's backpack to use in the future. I wish I could save these codes posted on boards for reference. I suppose the Print Screen button and paste in to image editor would do that?
(Fun fact: For a few days, you could backpack scripts from the forums. It was removed, I guess just because it wasn't typically useful enough?)
- ScolderCreations
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
maybe it was to prevent hacked blocks? (Fun fact: For a few days, you could backpack scripts from the forums. It was removed, I guess just because it wasn't typically useful enough?)
- the2000
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
I'm assuming that it just prevented you from backpacking them if the blocks were invalid. Even if it didn't, getting rid of the entire feature permanently sounds like an unnecessarily extreme measure to prevent that. I'm pretty sure you're allowed to share projects using hacked blocks anyway; I can't recall ever hearing about anyone getting in trouble for it.maybe it was to prevent hacked blocks? (Fun fact: For a few days, you could backpack scripts from the forums. It was removed, I guess just because it wasn't typically useful enough?)
Last edited by the2000 (June 29, 2021 23:35:27)
- kccuber
- Scratcher
1000+ posts
Suggestion: Repeat while key pressed, and On Single Key presses.
whoa lets not get offtopic please.I'm assuming that it just prevented you from backpacking them if the blocks were invalid. Even if it didn't, getting rid of the entire feature permanently sounds like an unnecessarily extreme measure to prevent that. I'm pretty sure you're allowed to share projects using hacked blocks anyway; I can't recall ever hearing about anyone getting in trouble for it.maybe it was to prevent hacked blocks? (Fun fact: For a few days, you could backpack scripts from the forums. It was removed, I guess just because it wasn't typically useful enough?)
A better workaround for “when key held down” is this:
if <<key [... v] pressed?> and <(key still pressed) = [0]>> then
...
set [key still pressed? v] to [1]
else
if <not <key [... v] pressed?>> then
set [key still pressed? v] to [0]
end
end
and for while key pressed:
repeat until <not <key [... v] pressed?>>
...
end
Last edited by kccuber (June 30, 2021 02:11:54)
- Discussion Forums
- » Suggestions
- » Suggestion: Repeat while key pressed, and On Single Key presses.