<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindow/selectNextKeyView(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindow(im)selectNextKeyView:"
  },
  "title" : "selectNextKeyView(_:)"
}
-->

# selectNextKeyView(_:)

Searches for a candidate next key view and, if it finds one, tries to make it the first responder.

```
func selectNextKeyView(_ sender: Any?)
```

## Parameters

`sender`

The message’s sender.

## Discussion

The candidate is one of the following (which this function searches for in this order):

- The current first responder’s next valid key view, which the [`nextValidKeyView`](/documentation/AppKit/NSView/nextValidKeyView) method of `NSView` returns
- The object [`initialFirstResponder`](/documentation/AppKit/NSWindow/initialFirstResponder) designates as the window’s initial first responder if it returns <doc://com.apple.documentation/documentation/Swift/true> to an [`acceptsFirstResponder`](/documentation/AppKit/NSResponder/acceptsFirstResponder) message
- Otherwise, the initial first responder’s next valid key view, which may be `nil`

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)