# How to detect simultaneous keypress in p5.js

**URL:** <https://discourse.processing.org/t/how-to-detect-simultaneous-keypress-in-p5-js/9264>\
**Category:** Beginners\
**Created:** [March 13, 2019, 12:51pm UTC](https://discourse.processing.org/t/how-to-detect-simultaneous-keypress-in-p5-js/9264 "2019-03-13T12:51:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jithin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jithin/32/122_2.png) [@Jithin](https://discourse.processing.org/u/Jithin)\
**Post date:** [March 13, 2019, 12:51pm UTC](https://discourse.processing.org/t/how-to-detect-simultaneous-keypress-in-p5-js/9264/1 "2019-03-13T12:51:22Z")

</div>

I’m trying to implement an undo functionality in a sketch. I need to detect simultaneous key press in p5. i.e ‘Ctrl’ and ‘z’ together? Is it possible?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [March 13, 2019, 1:17pm UTC](https://discourse.processing.org/t/how-to-detect-simultaneous-keypress-in-p5-js/9264/2 "2019-03-13T13:17:13Z")

</div>

like this?  
[https://editor.p5js.org/kll/sketches/j0ybQZIxHD](https://editor.p5js.org/kll/sketches/j0ybQZIxHD)

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 13, 2019, 1:34pm UTC](https://discourse.processing.org/t/how-to-detect-simultaneous-keypress-in-p5-js/9264/3 "2019-03-13T13:34:54Z")

</div>

[p5js.org/reference/#/p5/keyTyped](http://p5js.org/reference/#/p5/keyTyped)

```auto
function keyTyped() {
  const k = keyCode;

  if (k == 26) print('CTRL + Z');

  return false;
}

```
