No, that wouldn't change anything(At least, I don't think it would in JavaScript). I tested the same sort of thing in C and the syntax that he used(So, two pairs of parentheses inside a pair of parentheses), does work. Languages like JS inherit heavily from C, so if those two pairs of parentheses inside the condition were to be removed, it wouldn't change much at all, except for the way it was written.Master Yoda said:Hi @RyuuSan perhaps trying removing the second pair of () from your condition. Not sure if that will work but perhaps it might.
It doesn’t hurt to try it..No, that wouldn't change anything(At least, I don't think it would in JavaScript). I tested the same sort of thing in C and the syntax that he used(So, two pairs of parentheses inside a pair of parentheses), does work. Languages like JS inherit heavily from C, so if those two pairs of parentheses inside the condition were to be removed, it wouldn't change much at all, except for the way it was written.
Using something like pairs of parentheses inside a pair of parentheses is acceptable and it can possibly be used to make the code more readable, depending on the language, it's syntax, and the variables in use. Although, do note that there are times when a pair of parentheses inside a pair of parentheses are mandatory.
Thank you for sharing your solution! However, just make sure you wrap your code BBCode. Makes it easier to look atif kePressed is boolean all you need to do is check it.
keyPressed = true;
key = 'a';
if (keyPressed && key === 'a') {
console.log('yes');
} else {
console.log('no');
}
That honestly sounds like that could be it! Very neat. Thanks for sharing the link @Ghost.Most likely because the key pressed doesn't actually have a normal value.
So for example, in JS the key code for the letter 'a' would be '97'. This might be a problem if the key variable is grabbing the unicode value of the key instead of the letter "a".
![]()
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browserwww.w3schools.com
Hey.
I think it'd be better if we got to see more of the code. Mainly where and how you've declared and initialised your variables. Also, I don't think that println() is actually a thing in JS, but maybe that's just me. I don't work with JS, but that doesn't mean that I cannot help you.
Thank you for stating what you're using. But, I think it would've been better if you specified what you were using in the original post.Oh, I'm coding with Processing.JS right now. I couldn't find it on the menu so I just picked JavaScript.
Did the key codes information help you fix it?Oh, I'm coding with Processing.JS right now. I couldn't find it on the menu so I just picked JavaScript.