# How to detect global keystrokes?

**URL:** <https://discourse.processing.org/t/how-to-detect-global-keystrokes/27413>\
**Category:** Libraries\
**Created:** [January 27, 2021, 5:02pm UTC](https://discourse.processing.org/t/how-to-detect-global-keystrokes/27413 "2021-01-27T17:02:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dacoconutchemist](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dacoconutchemist/32/12134_2.png) [@dacoconutchemist](https://discourse.processing.org/u/dacoconutchemist)\
**Post date:** [January 27, 2021, 5:02pm UTC](https://discourse.processing.org/t/how-to-detect-global-keystrokes/27413/1 "2021-01-27T17:02:42Z")

</div>

Is there a way to detect keystrokes when the sketch window is not active?  
I would like to read each keyPressed event even if another application has focus and the sketch is in background.

---

<div class="post-metadata">

**Author:** ![WeinSim](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@WeinSim](https://discourse.processing.org/u/WeinSim)\
**Post date:** [January 27, 2021, 7:30pm UTC](https://discourse.processing.org/t/how-to-detect-global-keystrokes/27413/2 "2021-01-27T19:30:14Z")

</div>

I found this on StackOverflow, maybe that helps?

> <https://stackoverflow.com/questions/16179923/how-to-capture-global-key-presses-in-java>

---

<div class="post-metadata">

**Author:** ![dacoconutchemist](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dacoconutchemist/32/12134_2.png) [@dacoconutchemist](https://discourse.processing.org/u/dacoconutchemist)\
**Post date:** [January 27, 2021, 8:34pm UTC](https://discourse.processing.org/t/how-to-detect-global-keystrokes/27413/3 "2021-01-27T20:34:18Z")

</div>

lemme check…  
This is great, but how to import it as a library?
