Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Detect shift key? how?
- BED_NOOB
-
Scratcher
12 posts
Detect shift key? how?
So i made a 3D game and i want to add sprinting using a shift key detector. I tried the Javascript key code event but it didnt work
<key [ shift] pressed?> and <key [ 16] pressed?> didnt work i used the join
Last edited by BED_NOOB (Oct. 9, 2023 11:59:25)
- Cool_Dude2022
-
Scratcher
500+ posts
Detect shift key? how?
There was already a post similar to this, they suggested using the code:
I'm not sure if this would work, but it doesn't hurt to try.
Here's the link: https://scratch.mit.edu/discuss/topic/372044/?page=1#post-4072046
EDIT: I've tested it, and it doesn't seem to work. However, I noticed when I put enter, it said true, so it indicated I pressed the enter button. Instead of using the shift key for sprinting, you can use the enter key. I'd mess around with it more, but I'm busy, maybe another combination such as “left shift” would work, it just depends on what the key is called.
<key (join [enter] [ ]) pressed?>
I'm not sure if this would work, but it doesn't hurt to try.
Here's the link: https://scratch.mit.edu/discuss/topic/372044/?page=1#post-4072046
EDIT: I've tested it, and it doesn't seem to work. However, I noticed when I put enter, it said true, so it indicated I pressed the enter button. Instead of using the shift key for sprinting, you can use the enter key. I'd mess around with it more, but I'm busy, maybe another combination such as “left shift” would work, it just depends on what the key is called.
Last edited by Cool_Dude2022 (Oct. 9, 2023 13:35:35)
- RokCoder
-
Scratcher
1000+ posts
Detect shift key? how?
So i made a 3D game and i want to add sprinting using a shift key detector. I tried the Javascript key code event but it didnt workYou can't detect if the shift key is pressed in a Scratch project. The closest you'd get would be scanning the result of an ask block to see which letters are capitals and which are lower case.<key [ shift] pressed?> and <key [ 16] pressed?> didnt work i used the join
Note that you can detect the shift key using TurboWarp and there's no reason the Scratch source code can't be updated to allow this - they have just decided against it is all.
Last edited by RokCoder (Oct. 9, 2023 14:00:14)
- BED_NOOB
-
Scratcher
12 posts
Detect shift key? how?
I have tried using enter but that juts feels weird. I might go into the JSON file and check if shift is possible.
- KaaBEL_sk
-
Scratcher
100+ posts
Detect shift key? how?
Shift is not
The only use of editing JSON is to edit hat blocks to detectable keys (that are missing in dropdown):
I have tried using enter but that juts feels weird. I might go into the JSON file and check if shift is possible.possible in vanilla scratch 3.0. I used “&” key as the closest key to it, together with shift that works on TurboWarp as mentioned. To test whether certain key is working use something like
repeat until <key (join [enter] []) pressed?> // make sure the result of join doesn't contain spaces + it should be small case(in TW after setting the key for testing) click the repeat so it highlights that the script is running, than if you press the key and the loop stops it means scratch/TurboWarp(testing in TW) allows you to detect the key.
end
The only use of editing JSON is to edit hat blocks to detectable keys (that are missing in dropdown):
when [& v] key pressed
- BED_NOOB
-
Scratcher
12 posts
Detect shift key? how?
Im gonna try importing from turbowarp and see if it works.
EDIT: it doesn't work because its using join.
EDIT: it doesn't work because its using join.
Last edited by BED_NOOB (Oct. 11, 2023 10:34:30)
- han614698
-
Scratcher
1000+ posts
Detect shift key? how?
(#7)You can also detect !, @, # etc, things that need the shift key pressed.
snip
I've seen things where you tape down the one key, and then you have a working keyboard since “1” would just mean usual and “!” would mean shift.
Last edited by han614698 (Aug. 12, 2024 01:13:04)
- TheNoisyNoisy
-
Scratcher
100+ posts
Detect shift key? how?
hm, interesting idea. that would in fact work(#7)You can also detect !, @, # etc, things that need the shift key pressed.
snip
I've seen things where you tape down the one key, and then you have a working keyboard since “1” would just mean usual and “!” would mean shift.
- tuanyan
-
Scratcher
1 post
Detect shift key? how?
here is one example.
https://scratch.mit.edu/projects/1056875624/
you can detect like litierally every other key other than the function keys and the left and right rows. ctrl, alt, fn, delete, and shift are all out of the question.
https://scratch.mit.edu/projects/1056875624/
you can detect like litierally every other key other than the function keys and the left and right rows. ctrl, alt, fn, delete, and shift are all out of the question.
Last edited by tuanyan (Aug. 18, 2024 18:20:17)
- Discussion Forums
- » Help with Scripts
-
» Detect shift key? how?






