Home Explore Blog CI



nushell

commands/docs/input_listen.md
7b0d761b2dc36869d15fdf2d780c49ba51156efa42b8e6380000000300000748
---
title: input listen
categories: |
  platform
version: 0.104.0
platform: |
  Listen for user interface event.
usage: |
  Listen for user interface event.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `input listen` for [platform](/commands/categories/platform.md)

<div class='command-title'>Listen for user interface event.</div>

## Signature

```> input listen {flags} ```

## Flags

 -  `--types, -t {list<string>}`: Listen for event of specified types only (can be one of: focus, key, mouse, paste, resize)
 -  `--raw, -r`: Add raw_code field with numeric value of keycode and raw_flags with bit mask flags


## Input/output types:

| input   | output                                           |
| ------- | ------------------------------------------------ |
| nothing | record\<keycode: string, modifiers: list\<string\>\> |
## Examples

Listen for a keyboard shortcut and find out how nu receives it
```nu
> input listen --types [key]

```

## Notes
There are 5 different type of events: focus, key, mouse, paste, resize. Each will produce a
corresponding record, distinguished by type field:
```
    { type: focus event: (gained|lost) }
    { type: key key_type: <key_type> code: <string> modifiers: [ <modifier> ... ] }
    { type: mouse col: <int> row: <int> kind: <string> modifiers: [ <modifier> ... ] }
    { type: paste content: <string> }
    { type: resize col: <int> row: <int> }
```
There are 6 `modifier` variants: shift, control, alt, super, hyper, meta.
There are 4 `key_type` variants:
    f - f1, f2, f3 ... keys
    char - alphanumeric and special symbols (a, A, 1, $ ...)
    media - dedicated media keys (play, pause, tracknext ...)
    other - keys not falling under previous categories (up, down, backspace, enter ...)

Chunks
3a8b72af (1st chunk of `commands/docs/input_listen.md`)
Title: input listen - Platform Command
Summary
The `input listen` command allows users to listen for user interface events within the Nushell platform. It supports filtering by event types (focus, key, mouse, paste, resize) and provides detailed information about each event, including keycodes, modifiers, and mouse coordinates. The command outputs records detailing the event type and relevant data.