# Struct `kurogane::KeyPress`

```rust
pub struct KeyPress { /* private fields */ }
```

A key the user pressed, passed to [`App::on_key`](https://kurogane-rs.org/docs/api/app/app.md#method.on_key).

[crate::App::on_key]: https://kurogane-rs.org/docs/api/app/app.md#method.on_key

## Methods

### `key`

```rust
pub fn key(&self) -> Key
```

The key.

### `modifiers`

```rust
pub fn modifiers(&self) -> Modifiers
```

The modifier keys held with it.

### `character`

```rust
pub fn character(&self) -> Option<char>
```

Returns the character the press types. There is none with a modifier
that turns it into a control character (Ctrl+W) and none for keys
that type nothing (F5, the arrows).

### `in_editable_field`

```rust
pub fn in_editable_field(&self) -> bool
```

Whether the focus is in a field the user types into (an input, a
text area, an editable element).

### `repeat`

```rust
pub fn repeat(&self) -> bool
```

Whether the key is held down and this press is its repeat.

### `browser`

```rust
pub fn browser(&self) -> Option<BrowserId>
```

The browser the key went to.

### `command`

```rust
pub fn command(&self) -> Option<ChromeCommand>
```

Returns the command the key runs as one of Kurogane's shortcuts on
any OS. Ctrl+W (Cmd+W on macOS) is [`Close`](https://kurogane-rs.org/docs/api/requests/chromecommand.md#variant.Close).
Ctrl+R and F5 are [`Reload`](https://kurogane-rs.org/docs/api/requests/chromecommand.md#variant.Reload). Ctrl+Shift+I
(Cmd+Option+I) and F12 are [`DevTools`](https://kurogane-rs.org/docs/api/requests/chromecommand.md#variant.DevTools).
macOS's Cmd+Q quits and names no command. A browser embedded in the
application's own window runs no shortcut and names none.

[ChromeCommand::Close]: https://kurogane-rs.org/docs/api/requests/chromecommand.md#variant.Close
[ChromeCommand::Reload]: https://kurogane-rs.org/docs/api/requests/chromecommand.md#variant.Reload
[ChromeCommand::DevTools]: https://kurogane-rs.org/docs/api/requests/chromecommand.md#variant.DevTools

## Trait implementations

- `impl Clone for KeyPress`
- `impl Debug for KeyPress`

Source: https://github.com/0x48piraj/kurogane/blob/584c586118ee53cc04604007ee038557bd859092/kurogane/src/keys.rs#L21
