Discuss Scratch
- hoppingcoin404
-
Scratcher
100+ posts
Key Held Length
To put it simply, this block returns the number of seconds a certain key was pressed for.
(length key (space v) held for :: sensing) // resets when key released
<key (space v) held for (1) seconds? :: sensing> // true if the key is held for more than 1 second
- samuelthedude
-
Scratcher
500+ posts
Key Held Length
Can you just do
if <key [space v] pressed?> then
wait (1) secs
if <key [space v] pressed?> then
do things
end
end
- hoppingcoin404
-
Scratcher
100+ posts
Key Held Length
Can you just doThat doesn't workif <key [space v] pressed?> then
wait (1) secs
if <key [space v] pressed?> then
do things
end
end
- TimothyLawyer
-
Scratcher
1000+ posts
Key Held Length
Why do you need this?
when [space v] key pressed
reset timer
wait until <not <key [space v] pressed?>>
set [time key pressed v] to (timer)
- hoppingcoin404
-
Scratcher
100+ posts
Key Held Length
Why do you need this?That workaround doesn't work properlywhen [space v] key pressed
reset timer
wait until <not <key [space v] pressed?>>
set [time key pressed v] to (timer)
- TimothyLawyer
-
Scratcher
1000+ posts
Key Held Length
That workaround doesn't work properlyIt works to get the length of time a key is pressed.
<(time key pressed) > [1]> // true if the key is held for more than 1 secondor
<not <(time key pressed) < [1]>> // true if the key is held for 1 second or more
- hoppingcoin404
-
Scratcher
100+ posts
Key Held Length
The workaround doesn't work like the intended suggestionThat workaround doesn't work properlyIt works to get the length of time a key is pressed.<(time key pressed) > [1]> // true if the key is held for more than 1 secondor<not <(time key pressed) < [1]>> // true if the key is held for 1 second or more