# Testing for function keys in Processing 3.3.7

**URL:** <https://discourse.processing.org/t/testing-for-function-keys-in-processing-3-3-7/1891>\
**Category:** Beginners\
**Created:** [July 19, 2018, 3:27am UTC](https://discourse.processing.org/t/testing-for-function-keys-in-processing-3-3-7/1891 "2018-07-19T03:27:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MCCreeper8890](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mccreeper8890/32/751_2.png) [@MCCreeper8890](https://discourse.processing.org/u/MCCreeper8890)\
**Post date:** [July 19, 2018, 3:27am UTC](https://discourse.processing.org/t/testing-for-function-keys-in-processing-3-3-7/1891/1 "2018-07-19T03:27:14Z")

</div>

I am developing a “simple” game based around the QueasyCam library. So far, I have implemented terrain generation and a skydome. The things I will put in next are player movement, third-person capability, surface physics checking, etc. But, for some features, like toggleable fullscreen, I need to be able to check if the user pressed a function key, i.e. F5 to toggle third-person, F11 to toggle fullscreen.

I understand key, keyCode, keyPressed, keyPressed(), keyReleased(), keyClicked(), etc. However, none of them mention capability of checking the function keys. Does anyone know a solution for this? Or rather, should I opt for toggling certain features through other keys, that key and keyCode are shown to know in documentation?

---

<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:** [July 19, 2018, 3:32am UTC](https://discourse.processing.org/t/testing-for-function-keys-in-processing-3-3-7/1891/2 "2018-07-19T03:32:56Z")

</div>

[http://Studio.ProcessingTogether.com/sp/pad/export/ro.9cfU11egvzT6G](http://Studio.ProcessingTogether.com/sp/pad/export/ro.9cfU11egvzT6G)

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 19, 2018, 3:35am UTC](https://discourse.processing.org/t/testing-for-function-keys-in-processing-3-3-7/1891/3 "2018-07-19T03:35:18Z")

</div>

```java
void settings(){
  size(400,600);
}

void setup(){

  textAlign(CENTER,CENTER);
  rectMode(CENTER);
  
  fill(255);
  strokeWeight(2);
}

void draw(){
  background(0);
  
}

void keyPressed(){
  
  println(keyCode,key);

}

```

I tried in Win10 and alt/ctrl/shift respond to 18,17,16 for keyCode and key is set to ?

For F5 and F11 I get 116 and 122, same for key I get ?.

Not sure if this is valid cross platform. If you do a bit of research in the Java world, you should get an idea as it is very likely it will apply to Processing too.

Kf

---

<div class="post-metadata">

**Author:** ![MCCreeper8890](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mccreeper8890/32/751_2.png) [@MCCreeper8890](https://discourse.processing.org/u/MCCreeper8890)\
**Post date:** [July 19, 2018, 3:35am UTC](https://discourse.processing.org/t/testing-for-function-keys-in-processing-3-3-7/1891/4 "2018-07-19T03:35:58Z")

</div>

So, the function keys are detected by keyPressed() and keyReleased(), that’s nice. So now two options:

1. Test the key codes for all 12 normal function keys, and create constants for them.
2. Use the processing constants for those function keys, if such constants exist.

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 19, 2018, 3:47am UTC](https://discourse.processing.org/t/testing-for-function-keys-in-processing-3-3-7/1891/5 "2018-07-19T03:47:03Z")

</div>

You should check previous related posts: [https://discourse.processing.org/search?q=multiple%20keys](https://discourse.processing.org/search?q=multiple%20keys)

Kf
