Discuss Scratch

bungamer07
Scratcher
100+ posts

Detect if uppercase letter is pressed

How do I detect if an uppercase letter is pressed? I'm trying to make it so you can type but I need to be able to differentiate between uppercase and lowercase letters being typed.
MineTurte
Scratcher
1000+ posts

Detect if uppercase letter is pressed

You would need to use turbowarp. It comes with a special block that can sense if shift is pressed. From there you'd want to detect if both a shift key, and the main key is pressed. Hope this helps!
if <<key [shift] pressed?> and <key [e] pressed?>> then
set [letter] to [E]
end

Last edited by MineTurte (March 14, 2024 15:59:02)

bungamer07
Scratcher
100+ posts

Detect if uppercase letter is pressed

MineTurte wrote:

You would need to use turbowarp. It comes with a special block that can sense if shift is pressed. From there you'd want to detect if both a shift key, and the main key is pressed. Hope this helps!
if <<key [shift] pressed?> and <key [e] pressed?>> then
set [letter] to [E]
end
that works, thanks
Creeper_Kid_TNT
Scratcher
20 posts

Detect if uppercase letter is pressed

bungamer07 wrote:

MineTurte wrote:

You would need to use turbowarp. It comes with a special block that can sense if shift is pressed. From there you'd want to detect if both a shift key, and the main key is pressed. Hope this helps!
if <<key [shift] pressed?> and <key [e] pressed?>> then
set [letter] to [E]
end
that works, thanks
Or for more letters you use an iteration type thing like:
when [any v] key pressed
set [LetterIndexSearch v] to [0]
repeat until <<(LetterIndexSearch) > (length of [Letters v] :: list)> or <key [(item ((LetterIndexSearch) v) of [Letters v] :: list) v] pressed?>>
change [LetterIndexSearch v] by (1)
end
if <not <(LetterIndexSearch) > (length of [Letters v] :: list)>> then
(AddLetter (item ((LetterIndexSearch) v) of [Letters v] :: list) <key [shift v] pressed?>)
end
define AddLetter(Letter)<IsShift?>
Then add a list for shifted letters and check if its shifting after, if so, replace it with that item in the shift list

Last edited by Creeper_Kid_TNT (March 14, 2024 16:24:11)

MineTurte
Scratcher
1000+ posts

Detect if uppercase letter is pressed

Creeper_Kid_TNT wrote:

bungamer07 wrote:

MineTurte wrote:

You would need to use turbowarp. It comes with a special block that can sense if shift is pressed. From there you'd want to detect if both a shift key, and the main key is pressed. Hope this helps!
if <<key [shift] pressed?> and <key [e] pressed?>> then
set [letter] to [E]
end
that works, thanks
Or for more letters you use an iteration type thing like:
when [any v] key pressed
set [LetterIndexSearch v] to [0]
repeat until <<(LetterIndexSearch) > (length of [Letters v] :: list)> or <key [(item ((LetterIndexSearch) v) of [Letters v] :: list) v] pressed?>>
change [LetterIndexSearch v] by (1)
end
if <not <(LetterIndexSearch) > (length of [Letters v] :: list)>> then
define AddLetter(letter (LetterIndex) of [Letters])
end
Then add a list for shifted letters and check if its shifting after, if so, replace it with that item in the shift list

True

Powered by DjangoBB