Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I detect certain keys that aren't in the "key () pressed"?
- ThomasVG1
-
Scratcher
4 posts
How do I detect certain keys that aren't in the "key () pressed"?
I'm not talking using hacked blocks, they fixed those. I found out about a method for using other keys that aren't in the dropdown menu by putting a variable in that little slot of the “key () pressed”, but it doesn't work on things like backspace or shift or ctrl. I could be totally wrong, but I heard every key has a code thing that means something like pressing shift or something like that. Would setting the variable to said code and putting it in the “key () pressed” thing work?
- AProductions
-
Scratcher
500+ posts
How do I detect certain keys that aren't in the "key () pressed"?
Not supported by scratch, these are considered “hacks” and I believe are removed once found. Reason is likely due to the keys being used for shortcuts, etc. on the website + browser.
- Jaim_animation
-
Scratcher
94 posts
How do I detect certain keys that aren't in the "key () pressed"?
This is possible!
<key (join [enter] []) pressed?>//Put any other key's name on the join() block so it can detect the key,Hope this helps!
//but note that backspace is fully impossible.
//The more keys you can get by this method are koma(,), Fullstop(.), interrogative sign(?), enter(enter), shift(shift)etc.
//More Examples-
<key (join [?] []) pressed?>// You have to make sure one side of the join() block is blank and the other side contains
<key (join [shift] []) pressed?>// key name.
<key (join [.] []) pressed?>
Last edited by Jaim_animation (Oct. 11, 2023 06:40:26)
- ThomasVG1
-
Scratcher
4 posts
How do I detect certain keys that aren't in the "key () pressed"?
just tried the Join () method and it doesn't work on shift 
also my really smart friend says using the keyboard key codes would work in basically any other coding language but scratch, so that's a problem

also my really smart friend says using the keyboard key codes would work in basically any other coding language but scratch, so that's a problem
- medians
-
Scratcher
1000+ posts
How do I detect certain keys that aren't in the "key () pressed"?
There's no way to detect a lot of the keys in vanilla Scratch now, you used to be able to, but it involved hacked blocks, and they disallowed it in 3.0.
Not supported by scratch, these are considered “hacks” and I believe are removed once found. Reason is likely due to the keys being used for shortcuts, etc. on the website + browser.No, a lot of them are still available, and the hacked blocks were still possible until the release of 3.0.
Try out my project with the hacked script:ctrl, backspace., and stuff like that are still not possible.
https://scratch.mit.edu/projects/906183236/
- AProductions
-
Scratcher
500+ posts
How do I detect certain keys that aren't in the "key () pressed"?
Every programming language is different, scratch being possibly the simplest, but if by key codes you're referring to the numeric values attached to each key then these are rarely used in modern development as most of the time whatever library/module you're using will most likely have it's own functionality to handle this.
Some examples…
As you already know, scratch has:
Lets say you're using a library such as SFML with C++, then you have:
sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)
The only scenario where you'd require keycodes is if you're going barebones with a high level programming language (using no libraries/modules), in this case you would have to either use or assign constants for the required key codes and then use those.
For example, java has:
KeyEvent.VK_ESCAPE
But I wouldn't do this personally, not unless I decided to create a library of my own
Some examples…
As you already know, scratch has:
<key [ v] pressed?>
Lets say you're using a library such as SFML with C++, then you have:
sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)
The only scenario where you'd require keycodes is if you're going barebones with a high level programming language (using no libraries/modules), in this case you would have to either use or assign constants for the required key codes and then use those.
For example, java has:
KeyEvent.VK_ESCAPE
But I wouldn't do this personally, not unless I decided to create a library of my own
- AProductions
-
Scratcher
500+ posts
How do I detect certain keys that aren't in the "key () pressed"?
There's no way to detect a lot of the keys in vanilla Scratch now, you used to be able to, but it involved hacked blocks, and they disallowed it in 3.0.Still “hacks”, only reason they haven't been delt with since 3.0 is because this was the last notable update to happen to scratch. If they were supported then they would just be contained within the key pressed block. Hence, for continuity purposes it would be safer to not use them, but to each their ownNot supported by scratch, these are considered “hacks” and I believe are removed once found. Reason is likely due to the keys being used for shortcuts, etc. on the website + browser.No, a lot of them are still available, and the hacked blocks were still possible until the release of 3.0.Try out my project with the hacked script:ctrl, backspace., and stuff like that are still not possible.
https://scratch.mit.edu/projects/906183236/
- Jaim_animation
-
Scratcher
94 posts
How do I detect certain keys that aren't in the "key () pressed"?
Scratch is coded with Javascript so only powerfull keys works, keys like control(command on linux), f1 to f12, caps lock, tab, end, home,print screens are even undetectable by scratch website. But yeah, I saw many people that they are using the join() method to detect shift key. If it does not works for you, I am really sorry
. You can try any other key like enter(I am sure enter will work!), ?,coma, fullstop etc.
Oh, your smart freind talked the right but scratch is coded with javascript so their is some “join() glitch”. For example-
Hope it helped again!

. You can try any other key like enter(I am sure enter will work!), ?,coma, fullstop etc.Oh, your smart freind talked the right but scratch is coded with javascript so their is some “join() glitch”. For example-
delete (join [random] []) of [list v]will delete any random item of your list.
Hope it helped again!
Last edited by Jaim_animation (Oct. 12, 2023 07:57:23)
- medians
-
Scratcher
1000+ posts
How do I detect certain keys that aren't in the "key () pressed"?
Still “hacks”, only reason they haven't been delt with since 3.0 is because this was the last notable update to happen to scratch. If they were supported then they would just be contained within the key pressed block. Hence, for continuity purposes it would be safer to not use them, but to each their ownI mean they don't exist anymore, 3.0 got rid of them. It's not “since”.![]()
Oh, your smart freind talked the right but scratch is coded with javascript so their is some “join() glitch”. For example-They implemented that for the list blocks so that projects would be compatible with Scratch 1.x and 2.0, they also likely thought random would work.delete (join [random] []) of [list v]will delete any random item of your list.
Hope it helped again!
Last edited by medians (Oct. 12, 2023 12:59:30)
- Jaim_animation
-
Scratcher
94 posts
How do I detect certain keys that aren't in the "key () pressed"?
Are you forgot that javascript and lots of programming language has a keyword called random()(I think python is the only programming language which don't has the random() keyword), so that will be automaticly work even if scratch team don't add this to scratch's code.Still “hacks”, only reason they haven't been delt with since 3.0 is because this was the last notable update to happen to scratch. If they were supported then they would just be contained within the key pressed block. Hence, for continuity purposes it would be safer to not use them, but to each their ownI mean they don't exist anymore, 3.0 got rid of them. It's not “since”.
Oh, your smart freind talked the right but scratch is coded with javascript so their is some “join() glitch”. For example-They implemented that for the list blocks so that projects would be compatible with Scratch 1.x and 2.0, they also likely thought random would work.delete (join [random] []) of [list v]will delete any random item of your list.
Hope it helped again!
Also, scratch 3.0 didn't fully got rid of hacked blocks, you cannot create new hacked blocks but you can use old hacked blocks by putting on backpack(scratch backpack is always buggy)
PLEASE DON'T SHARE THOSE POSTS, THIS FORAM ISN'T CREATED FOR THESE DICCUSSIONS!
Last edited by Jaim_animation (Oct. 13, 2023 05:24:18)
- Jaim_animation
-
Scratcher
94 posts
How do I detect certain keys that aren't in the "key () pressed"?
Every programming language is different, scratch being possibly the simplest, but if by key codes you're referring to the numeric values attached to each key then these are rarely used in modern development as most of the time whatever library/module you're using will most likely have it's own functionality to handle this.Blah, he wanted for scratch, why you are advartising for other programming languages?
Some examples…
As you already know, scratch has:<key [ v] pressed?>
Lets say you're using a library such as SFML with C++, then you have:
sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)
The only scenario where you'd require keycodes is if you're going barebones with a high level programming language (using no libraries/modules), in this case you would have to either use or assign constants for the required key codes and then use those.
For example, java has:
KeyEvent.VK_ESCAPE
But I wouldn't do this personally, not unless I decided to create a library of my own![]()
- Jaim_animation
-
Scratcher
94 posts
How do I detect certain keys that aren't in the "key () pressed"?
You can use hacked blocks with proper safety, just use scratch's super buggy backpack and DO NOT SAVE FILES WITH HACKED BLOCKS ON YOUR COMPUTER, SCRATCH MIGHT CANNOT LOAD THESE!There's no way to detect a lot of the keys in vanilla Scratch now, you used to be able to, but it involved hacked blocks, and they disallowed it in 3.0.Still “hacks”, only reason they haven't been delt with since 3.0 is because this was the last notable update to happen to scratch. If they were supported then they would just be contained within the key pressed block. Hence, for continuity purposes it would be safer to not use them, but to each their ownNot supported by scratch, these are considered “hacks” and I believe are removed once found. Reason is likely due to the keys being used for shortcuts, etc. on the website + browser.No, a lot of them are still available, and the hacked blocks were still possible until the release of 3.0.Try out my project with the hacked script:ctrl, backspace., and stuff like that are still not possible.
https://scratch.mit.edu/projects/906183236/![]()
- AProductions
-
Scratcher
500+ posts
How do I detect certain keys that aren't in the "key () pressed"?
Every programming language is different, scratch being possibly the simplest, but if by key codes you're referring to the numeric values attached to each key then these are rarely used in modern development as most of the time whatever library/module you're using will most likely have it's own functionality to handle this.Blah, he wanted for scratch, why you are advartising for other programming languages?
Some examples…
As you already know, scratch has:<key [ v] pressed?>
Lets say you're using a library such as SFML with C++, then you have:
sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)
The only scenario where you'd require keycodes is if you're going barebones with a high level programming language (using no libraries/modules), in this case you would have to either use or assign constants for the required key codes and then use those.
For example, java has:
KeyEvent.VK_ESCAPE
But I wouldn't do this personally, not unless I decided to create a library of my own![]()
Scratch is a tool that serves the purpose of an introduction to programming for kids as a fun teaching method. Why would I not share a little knowledge on other languages? The majority of scratch users will be looking at moving onto a more advanced language after they've learned what they can from scratch and progress to college, uni, online courses, etc.
- medians
-
Scratcher
1000+ posts
How do I detect certain keys that aren't in the "key () pressed"?
Are you forgot that javascript and lots of programming language has a keyword called random()(I think python is the only programming language which don't has the random() keyword), so that will be automaticly work even if scratch team don't add this to scratch's code.I wasn't saying that programming languages didn't have a way to do it, I was saying that the Scratch Team kept it in likely because of the fact that there was (item (random v) of [list v]) and stuff like that in Scratch 2.0 and 1.x, so they wanted older projects to be compatible. And they decided to add it to the delete block as well, since the other blocks had a random option:
PLEASE DON'T SHARE THOSE POSTS, THIS FORAM ISN'T CREATED FOR THESE DICCUSSIONS!



Anyway, can we just say that this was answered already?
Edit: Oh and, I wasn't saying that 3.0 got rid of hacked blocks, just the ones that were used for doing what the original poster wanted broke and it was made impossible to detect these keys in vanilla Scratch. I would've said “hacked blocks”, not “the hacked blocks” if I meant all of them.
Last edited by medians (Oct. 13, 2023 13:02:38)
- CODEboT1000
-
Scratcher
9 posts
How do I detect certain keys that aren't in the "key () pressed"?
The way that I do that is with Addons…
Hehe.
Hehe.
Last edited by CODEboT1000 (Oct. 13, 2023 14:31:56)
- iiDk__
-
Scratcher
100+ posts
How do I detect certain keys that aren't in the "key () pressed"?
save a blank project with nothing but a key space pressed block in it, save it to your computer, renam eit to whatever.zip, go to the json, and replace the space with anything u want like < and >
- Jaim_animation
-
Scratcher
94 posts
How do I detect certain keys that aren't in the "key () pressed"?
The way that I do that is with Addons…Do not necropost! The creator of this forum already got the answer and this forum will be closed soon…
Hehe.
- Jaim_animation
-
Scratcher
94 posts
How do I detect certain keys that aren't in the "key () pressed"?
save a blank project with nothing but a key space pressed block in it, save it to your computer, renam eit to whatever.zip, go to the json, and replace the space with anything u want like < and >Do not necropost! The creator of this forum already got the answer and this forum will be closed soon…
- Jaim_animation
-
Scratcher
94 posts
How do I detect certain keys that aren't in the "key () pressed"?
Ops! I am sorryAre you forgot that javascript and lots of programming language has a keyword called random()(I think python is the only programming language which don't has the random() keyword), so that will be automaticly work even if scratch team don't add this to scratch's code.I wasn't saying that programming languages didn't have a way to do it, I was saying that the Scratch Team kept it in likely because of the fact that there was (item (random v) of [list v]) and stuff like that in Scratch 2.0 and 1.x, so they wanted older projects to be compatible. And they decided to add it to the delete block as well, since the other blocks had a random option:
PLEASE DON'T SHARE THOSE POSTS, THIS FORAM ISN'T CREATED FOR THESE DICCUSSIONS!
Anyway, can we just say that this was answered already?
Edit: Oh and, I wasn't saying that 3.0 got rid of hacked blocks, just the ones that were used for doing what the original poster wanted broke and it was made impossible to detect these keys in vanilla Scratch. I would've said “hacked blocks”, not “the hacked blocks” if I meant all of them.


But let us stop disscuccing about this, the creator of this forum already got the answer+this forum isn't created for this so this is already a double necropost and even this reply is! necropost isn't allowd, I'm fairing that scratch team will ban us.- Discussion Forums
- » Help with Scripts
-
» How do I detect certain keys that aren't in the "key () pressed"?