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

# beginSearchInteraction()

Starts a search interaction and moves the keyboard focus to the search field.

```
func beginSearchInteraction()
```

## Discussion

If the system displays a compressed search field, starting the search interaction expands the field to the width stored in the [`preferredWidthForSearchField`](/documentation/AppKit/NSSearchToolbarItem/preferredWidthForSearchField) property and moves the keyboard focus into the search field. Use [`beginSearchInteraction()`](/documentation/AppKit/NSSearchToolbarItem/beginSearchInteraction()) and [`endSearchInteraction()`](/documentation/AppKit/NSSearchToolbarItem/endSearchInteraction()) to programmatically control a search.

---

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)