---
title: "characters(byApplyingModifiers:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsevent/characters(byapplyingmodifiers:)"
---

# characters(byApplyingModifiers:)

Returns the new characters that result if you apply the specified modifier keys to the event.

## Declaration

```swift
func characters(byApplyingModifiers modifiers: NSEvent.ModifierFlags) -> String?
```

## Parameters

- `modifiers`: The modifier keys you want to apply to the event’s characters. These modifiers completely replace the existing modifiers in the event.

## Return Value

Return Value The characters that result from the application of the specified modifier keys. If the event contains invalid data, this method returns nil.

## Discussion

Discussion Call this method to determine what characters occur if you apply the specified modifier keys to this event. This method doesn’t modify the event itself, but returns a translation of the event’s data that replaces the existing modifier keys with the new ones you specify. Cal this method only for an event of type NSEvent.EventType.keyUp or NSEvent.EventType.keyDown.

## See Also

### Getting key event information

- [characters](appkit/nsevent/characters.md)
- [charactersIgnoringModifiers](appkit/nsevent/charactersignoringmodifiers.md)
- [keyCode](appkit/nsevent/keycode.md)
- [keyRepeatDelay](appkit/nsevent/keyrepeatdelay.md)
- [keyRepeatInterval](appkit/nsevent/keyrepeatinterval.md)
- [specialKey](appkit/nsevent/specialkey-swift.property.md)
- [Function-Key Unicode Values](appkit/function-key-unicode-values.md)
- [NSEvent.SpecialKey](appkit/nsevent/specialkey-swift.struct.md)
- [isARepeat](appkit/nsevent/isarepeat.md)
