# MIDI keyboard : can we know keys depress state?

**URL:** <https://forum.bome.com/t/midi-keyboard-can-we-know-keys-depress-state/4483>\
**Category:** Bome Products\
**Created:** [August 19, 2022, 8:25pm UTC](https://forum.bome.com/t/midi-keyboard-can-we-know-keys-depress-state/4483 "2022-08-19T20:25:57Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![SteveC](https://forum.bome.com/user_avatar/forum.bome.com/stevec/32/8250_2.png) [@SteveC](https://forum.bome.com/u/SteveC)\
**Post date:** [August 19, 2022, 8:51pm UTC](https://forum.bome.com/t/midi-keyboard-can-we-know-keys-depress-state/4483/2 "2022-08-19T20:51:35Z")

</div>

Hi,

This should help get you started. I do not use 127 global variable yet I bit map the key state of all notes into 4 global variables:

g0 - For notes 0-31  
g1 - For notes 32-63  
g2 - For notes 64-95  
g3 - For notes 96-127

Every time I press a note (note-on), I check which global variable to use and set a bit.  
Every time I release a note (note-off), I use the same logic to clear the bit.

So now in other translators (that I have not created), you should be able to look up the note’s on/off state by looking at a given bit in the appropriate global variable.

I’ve commented the rules to help you understand the logic.

You will need to use bit shifting logic to check if a bit is set (1) or clear (0).

[This post](https://forum.bome.com/t/bitwise-operations-and-reference/1862) should help with that.

[Note-On-Off-Bitmap.bmtp](https://forum.bome.com/uploads/short-url/b4m8eMcxPoELGtzbaaA1CB4lqyu.bmtp) (2.3 KB)

Steve Caldwell  
Bome Customer Care

* * *
_Also available for paid consulting services: bome@sniz.biz_

---

_[View the full topic](https://forum.bome.com/t/midi-keyboard-can-we-know-keys-depress-state/4483)._
