# Key == someVariable does not work

**URL:** <https://discourse.processing.org/t/key-somevariable-does-not-work/9130>\
**Category:** Beginners\
**Created:** [March 9, 2019, 12:02am UTC](https://discourse.processing.org/t/key-somevariable-does-not-work/9130 "2019-03-09T00:02:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jetjaguar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jetjaguar/32/1370_2.png) [@jetjaguar](https://discourse.processing.org/u/jetjaguar)\
**Post date:** [March 9, 2019, 12:02am UTC](https://discourse.processing.org/t/key-somevariable-does-not-work/9130/1 "2019-03-09T00:02:14Z")

</div>

I’d like to use a variable (int) with the key function, but it doesn’t work with or without single quotes. What can I do?

if(key == someVariable){  
…  
}

Thank you!

---

<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 9, 2019, 12:22am UTC](https://discourse.processing.org/t/key-somevariable-does-not-work/9130/2 "2019-03-09T00:22:00Z")

</div>

because key is a character not a number,  
better use  
[https://processing.org/reference/keyCode.html](https://processing.org/reference/keyCode.html)

```auto
int li = 76;
char lc = 'l';

void setup() {}
void draw() {}
void keyPressed() {
  println("key "+key+" keyCode "+keyCode);
  if ( key == 'l' ) println("see l");
  if ( key == lc ) println("again l");
  if ( keyCode == li ) println("also see l");
}

```

for some keys that is not consistent over all OS’s

pls also test how to use?

```auto
if ((int)key == lk ) println("can use number (int)'l' also");

```
