# Key and mouse pressed with boolean

**URL:** <https://discourse.processing.org/t/key-and-mouse-pressed-with-boolean/15274>\
**Category:** Coding Questions\
**Created:** [November 6, 2019, 9:57am UTC](https://discourse.processing.org/t/key-and-mouse-pressed-with-boolean/15274 "2019-11-06T09:57:52Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [November 11, 2019, 8:18pm UTC](https://discourse.processing.org/t/key-and-mouse-pressed-with-boolean/15274/13 "2019-11-11T20:18:44Z")

</div>

> [@vincentstrebelle](#):
>
> i will continue to search a solution for my problem

Were you able to resolve your problem? If not, would you be willing to restate what your problem is? For example “I am trying to count each time that the mouse [does something / is doing something]”.

I’ve looked at the original solution post that you reference – [Solution for repeating keyPressed while holding key - #11 by vincentstrebelle](https://discourse.processing.org/t/solution-for-repeating-keypressed-while-holding-key/3989/11) – and I’m still unclear on what you are trying to do. It seems as if you could simply duplicate the mouseRight code for both buttons and your problem would be solved?

Another option is to just put all your code in `mousePressed()` and use [mouseButton](https://processing.org/reference/mouseButton.html).

If you are counting clicks and don’t care about the attack vs. release, it is also even easier to just put the code in mouseReleased and check mouseButton. Then no boolean guard fields are necessary – you can do the whole thing in 5 lines of code.

---

_[View the full topic](https://discourse.processing.org/t/key-and-mouse-pressed-with-boolean/15274)._
