@Ed222
I'm not sure which version you saw because I was editing the original when you posted. In the edited version, the scancode for p=25 - I looked that up ahead of time.
iterations is just a count for the main do loop so that I can prove the program isn't being held up waiting for the p key to be released.
The flag to check for whether or not the p key has been pressed and released is called release.
if keystate(p)=1 and release=0
dec potions
release=1
endif
This block checks the keystate of the p key (scan code 25), if it is pressed, decreases the poition count and sets the release flag to 1. The next time through the loop if the release flag is not = 0 then it won't decrease the potion count.
if keystate(p)=0 then release=0
This checks if the p key has been released. If it has, then it sets release=0 so that the next time through the loop if p is pressed and release = 0 then another potion will be deducted. So all in all, if the p key is never released, the variable release will never get set back to 0 so another potion can't be used until the key is released.
{EDIT}
Obese's way is better
Enjoy your day.