We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am figuring out some stuff. I have created a small program that uses : keyPressed and keyReleased in a conditional inside the DRAW function. The problem is that PFPython doesn't recognize keyReleased by itself, and it wants it as a function. Why is that? For example, I can use either keyPressed() or keyPressed: -- but I cannot use keyReleased() and keyReleased:
Answers
ok, here is the code. The challenge I am having is that when the mouse is pressed, it starts to draw - works great. When the keyboard is pressed, it starts to draw, works great as well. The challenge is that if I hold down a key on the keyboard, it will NOT stop drawing. So I am trying to eliminate this issue.
My understanding is that different OS provide different behavior for keyPressed. I believe you can configure this behavior in the configuration menu of your input devices provided by your OS. Regardless of this behavior, the solution is to use keyReleased(). However, I am not sure how the Python mode works so I cannot comment on performance there. What I could do is provide some suggestions.
Firs of all, mousePressed, as a variable available in many modes. however, mouseReleased does not exist. There is nothing stopping you to implement your own mouseReleased nevertheless. For example, in java I will do:
I hope this help,
Kf
Thank you but I want KEY RELEASED. I think the problem is that when a key is pressed, KEY becomes that ASCII number. I need to convert that number back to NOTHING when the key is released. I think that is what I need.
I see what you are saying now. I am going to try the boolean, but unfortunately, it ,for some reason, it never makes it to the Keypressed part of the conditional - because I can't get the TEXT to print. Here is what I tried.
Your example above doesn't refer to key at all. Try setting the key to zero.
Kf
Thank you, but it doesn't work if you get rid of the background(0). I want it so that when you hold down a key, it draws. When you release the key (doesn't matter which key at this point), it stops drawing. What you sent me doesn't seem to do that.
I believe it is finding a way to set this.key to RELEASE. I cannot set it to ZERO or " " because it still considers the key to be pressed for some reason.
Well, I found a work around, using the this.key command you suggested. I am guessing there isn't really a keyRelease that I can use, so I figured a toggle would work better with two keys being "s" for ON and "q" for OFF when it comes to drawing. It seems to work