Discuss Scratch

CatClawz_
Scratcher
500+ posts

typing engine

working on a typing engine, my issue is that if yo type too fast it screws up the letters, can anyone help?
https://scratch.mit.edu/projects/981148981/editor
sashimiricedev
Scratcher
100+ posts

typing engine

Try making a list of all the characters you have typed. Do something like this.

when [any v] key pressed
Detect Key :: custom
add (Key) to [Keys v]

forever
repeat (length of [Keys v]
set [My Text v] to (join (My Text) (item (1) of [Keys v]))
delete (1) of [Keys v]
end
CatClawz_
Scratcher
500+ posts

typing engine

sashimiricedev wrote:

Try making a list of all the characters you have typed. Do something like this.

when [any v] key pressed
Detect Key :: custom
add (Key) to [Keys v]

forever
repeat (length of [Keys v]
set [My Text v] to (join (My Text) (item (1) of [Keys v]))
delete (1) of [Keys v]
end
my issue with that is that the thing i use to detect the keys will record multiple key presses, so the key will add itself to the list more than once, thanks for the input though!
RokCoder
Scratcher
1000+ posts

typing engine

Your project isn't shared but the usual approach would be along these lines -

when green flag clicked
set [_keys v] to [abcdefghijklmnopqrstuvwxyz 0123456789] // Whatever keys you want to detect

And then create a (non-refresh) custom block to call each frame to see what key is pressed (if any) -

define _key = check keys
set [_index v] to [1]
repeat (length of (_keys))
set [_key v] to (letter (_index) of (_keys))
if <key (_key) pressed?> then
stop [this script v]
end
change [_index v] by [1]
end
set [_key v] to [] // Setting it to nothing as no key has been detected

Powered by DjangoBB