How do I detect if the enter (‘return’) key is pressed?
function keyboard(key)
If key == RETURN then
--do whatever
end
end
Interestingly enough, I had the same problem as @warspyking but I solved it in a different way. Apparently, the code you provided is equivalent to:
function keyboard(key)
if key=="\
" then
--do whatever
end
end
I didn’t know about the RETURN constant, so this worked well enough for me. I guess this won’t be surprising to a lot of people, but I was impressed that I could test if a key was something like "
."
@CodeaNoob actually, I think it is that way for a lot of languages. Generally
means newline, which is usually equivalent to return.