# Color polygon only when key is pressed

**URL:** <https://discourse.psychopy.org/t/color-polygon-only-when-key-is-pressed/26699>\
**Category:** Builder\
**Created:** [January 6, 2022, 8:30am UTC](https://discourse.psychopy.org/t/color-polygon-only-when-key-is-pressed/26699 "2022-01-06T08:30:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [January 6, 2022, 8:58am UTC](https://discourse.psychopy.org/t/color-polygon-only-when-key-is-pressed/26699/4 "2022-01-06T08:58:39Z")

</div>

event.getKeys can’t tell when a key is released. This is possible, but the coding is a bit more involved (so I often use mouse buttons when I want to monitor for the release as well). Alternatively, the triangle could change colour for a fixed length of time.

Becca’s example here might help.

> [@Recording KeyRelease data - iohub or keyBoard?](https://discourse.psychopy.org/t/recording-keyrelease-data-iohub-or-keyboard/26257/2):
>
> Hi There, Just to check that this is a study that will be run locally ? If so I think this demo should help [fetch duration.psyexp](https://discourse.psychopy.org/uploads/short-url/jCvaUqkDKlVqzEClYAGCfcXGu6Q.psyexp) (13.8 KB) Participants must hold down 2 keys for the trial to stat (the “1” and “2” keys) then they lift one and we show them which they lifted first. Hope this helps, Becca

---

_[View the full topic](https://discourse.psychopy.org/t/color-polygon-only-when-key-is-pressed/26699)._
