---
title: "command(for:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkwebextensioncontext/command(for:)"
---

# command(for:)

Retrieves the command associated with the given event without performing it.

## Declaration

```swift
func command(for event: NSEvent) -> WKWebExtension.Command?
```

## Parameters

- `event`: The event for which to retrieve the corresponding command.

## Return Value

Return Value The command associated with the event, or nil if there is no such command.

## Discussion

Discussion Returns the command that corresponds to the provided event, if such a command exists. This provides a way to programmatically determine what action would occur for a given event, without triggering the command.
