---
title: "keyDown(with:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/nshostingview/keydown(with:)"
---

# keyDown(with:)

Called when the user presses a key on the keyboard while this view is in the responder chain.

## Declaration

```swift
@MainActor @preconcurrency override dynamic func keyDown(with event: NSEvent)
```

## See Also

### Managing keyboard interaction

- [keyUp(with:)](swiftui/nshostingview/keyup(with:).md)
- [performKeyEquivalent(with:)](swiftui/nshostingview/performkeyequivalent(with:).md)
- [insertText(_:)](swiftui/nshostingview/inserttext(_:).md)
- [didChangeValue(forKey:)](swiftui/nshostingview/didchangevalue(forkey:).md)
- [makeTouchBar()](swiftui/nshostingview/maketouchbar().md)
