# 3.9.20 Key Listener

In certain structural design workflows, it is desirable to switch seamlessly between different views or states of a model in the Rhino viewport without interacting directly with Grasshopper. For these situations, the **Key Listener** component provides an effective solution.

This component triggers updates to downstream components whenever the user presses **Shift** plus a function key. Its output "Counter" returns the number of key presses since the definition was opened. By default, the component listens for the **Shift + F1** combination. Through the **Fn** input, you can specify a number between 1 and 12 to make it respond to the corresponding function key.

<figure><img src="https://2671626451-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6rkhS8IteqWJRfUuJlL5%2Fuploads%2FVHXgfkkzK4Ks4XMkWZBY%2Fkeylistener.png?alt=media&#x26;token=7f852212-3648-47d0-9310-6e3be1516c65" alt=""><figcaption><p>Fig. 3.9.20.1: Using a Key Listener component for switching free handedly between different views of a model.</p></figcaption></figure>

Figure 3.9.20.1 illustrates a section of a definition where a Key Listener, combined with a Stream Gate, controls which aspects of the model are displayed. In the first variant, the user cycles through available views by repeatedly pressing **Shift + F1**. In the second variant, **Shift + F1** advances to the next view, while **Shift + F2** returns to the previous one.

{% file src="<https://2671626451-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6rkhS8IteqWJRfUuJlL5%2Fuploads%2FOPW3egmO0X7ooTG0YQE1%2FKeyListener_ToggleView.gh?alt=media&token=3e790f54-69a8-4683-804e-dd2e7006dbbc>" %}
