Discuss Scratch

Fuzzee_animations
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

Hello! Is there a way to make the <key pressed> block case sensitive? I tried with costumes and fiddled with that for a bit, but with no luck. Is there a way to be able to detect whether the user types a capital or lowercase letter? Thanks!!!
awesome-llama
Scratcher
1000+ posts

Detect capital/lowercase keys with <when key pressed> block

It isn't possible. The shift key is not detected and there is also no differentiation for case if a letter was typed into the input. The only thing close is that some symbols that typically require holding shift can be detected.

You can see the code here: https://github.com/scratchfoundation/scratch-editor/blob/develop/packages/scratch-vm/src/io/keyboard.js
1234not123abc
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

Fuzzee_animations wrote:

Hello! Is there a way to make the <key pressed> block case sensitive? I tried with costumes and fiddled with that for a bit, but with no luck. Is there a way to be able to detect whether the user types a capital or lowercase letter? Thanks!!!
there is a solution, that is that costume names are case sensitive!
Fuzzee_animations
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

But how specifically would you go about doing this? I have a sprite with capital/lowercase costumes, but I haven't figured out how to make it actually work. Thanks!
1234not123abc
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

switch costume to [ (foo)]
if <(costume numebr) > [blabala]> then
capital
end

Last edited by 1234not123abc (Sept. 12, 2025 20:37:02)

1234not123abc
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

1234not123abc wrote:

switch costume to [ (foo)]
if <(costume numebr) > [blabala]> then
capital
end
this is if the capital letters are at the bottom of the costumes
Fuzzee_animations
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

Right, that works for detecting the capital, but how can you make the keypress case sensitive with that?
deking0911
Scratcher
65 posts

Detect capital/lowercase keys with <when key pressed> block

Fuzzee_animations wrote:

Hello! Is there a way to make the <key pressed> block case sensitive? I tried with costumes and fiddled with that for a bit, but with no luck. Is there a way to be able to detect whether the user types a capital or lowercase letter? Thanks!!!
when green flag clicked
set [shift] to [shift]
forever
if <key (shift) pressed?> then
if <key [any] pressed?> then
your code here
end
end
10goto10
Scratcher
1000+ posts

Detect capital/lowercase keys with <when key pressed> block

deking0911 wrote:

when green flag clicked
set [shift] to [shift]
forever
if <key (shift) pressed?> then
if <key [any] pressed?> then
your code here
end
end
This does not work for me on standard Scratch. Are you using some modified version of Scratch?
divisorsinvises
Scratcher
31 posts

Detect capital/lowercase keys with <when key pressed> block

10goto10 wrote:

(#9)

deking0911 wrote:

when green flag clicked
set [shift] to [shift]
forever
if <key (shift) pressed?> then
if <key [any] pressed?> then
your code here
end
end
This does not work for me on standard Scratch. Are you using some modified version of Scratch?
Even using an extension, I can't find shift.
Fuzzee_animations
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

this does not seem to work for me either.
1234not123abc
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

Fuzzee_animations wrote:

this does not seem to work for me either.
just use the prompt function already
also why do u need to detect capitals

Last edited by 1234not123abc (Sept. 16, 2025 15:49:44)

OlivePen
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

Fuzzee_animations wrote:

Hello! Is there a way to make the <key pressed> block case sensitive? I tried with costumes and fiddled with that for a bit, but with no luck. Is there a way to be able to detect whether the user types a capital or lowercase letter? Thanks!!!

There is no coded way of getting the code blocks to detect the shift key or the caps lock. You either have to implement a shift key as a sprite for players to click, use the question and answer block, have an alt key equal to the shift key (i.e up arrow) or leave it be. Scratch just never put the shift key into their coding system. I believe Turbowarp did but not Scratch.
EpsilonX
Scratcher
42 posts

Detect capital/lowercase keys with <when key pressed> block

1234not123abc wrote:

Fuzzee_animations wrote:

Hello! Is there a way to make the <key pressed> block case sensitive? I tried with costumes and fiddled with that for a bit, but with no luck. Is there a way to be able to detect whether the user types a capital or lowercase letter? Thanks!!!
there is a solution, that is that costume names are case sensitive!
Yes, but that only works if you are using the ask/answer blocks. Scratch can’t differentiate lowercase and uppercase key presses.
WafflesYouTubeMC
Scratcher
500+ posts

Detect capital/lowercase keys with <when key pressed> block

try making a different key shift? like dedicate a specific key to shift

<key (join [en] [ter]) pressed?>

if <key (join [en] [ter]) pressed?> then
if <key [any v] pressed?> then
your code here
end
end

Last edited by WafflesYouTubeMC (Sept. 16, 2025 18:38:35)

1234not123abc
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

EpsilonX wrote:

1234not123abc wrote:

Fuzzee_animations wrote:

Hello! Is there a way to make the <key pressed> block case sensitive? I tried with costumes and fiddled with that for a bit, but with no luck. Is there a way to be able to detect whether the user types a capital or lowercase letter? Thanks!!!
there is a solution, that is that costume names are case sensitive!
Yes, but that only works if you are using the ask/answer blocks. Scratch can’t differentiate lowercase and uppercase key presses.
the owner of this topic already said that! I just didn't read the title correctly
The_Cool_Test_Alt
Scratcher
100+ posts

Detect capital/lowercase keys with <when key pressed> block

deking0911 wrote:

when green flag clicked
set [shift] to [shift]
forever
if <key (shift) pressed?> then
if <key [any] pressed?> then
your code here
end
end

Only enter can be detected this way. Not shift.

Powered by DjangoBB