All that this following code does is identify if keys "a" or "d" are being being pressed or not. Later on you then check if these values are true, but this really seems like unnecessary work to me. You could write the a single movement function that you call whenever a specific key is pressed down, etc.

Now, thirdly, the reason as to why you are encountering your double jump problem is because a misunderstanding of how the key function actually works. Runtime:addEventListener("key",move) means that your function move runs every time any key is pressed, not just the ones that you've written some functionality for. If you look at your code:

First you check if the user is pressing down the spacebar and if the double jump counter is within limits. This means that pressing spacebar once or holding spacebar down and then pressing any other key on the keyboard will both satisfy this requirement.

Next you check if(currentlyDown.a ==falseor currentlyDown.d ==false)then, which is true as long as the user is not pressing down both a and d keys at the same time. So, in total, your rect will jump as long as the user presses spacebar, or holds down the spacebar while pressing any key on their keyboard, as long as they don't hold spacebar, a and d keys (all three keys) down at the same time.

This entire issue would be prevented if you ran the jumping code only in the event that spacebar is pressed instead of tracking whether or not spacebar is held down or not.