<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGEvent/keyboardSetUnicodeString(stringLength:unicodeString:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "c:@F@CGEventKeyboardSetUnicodeString"
  },
  "title" : "keyboardSetUnicodeString(stringLength:unicodeString:)"
}
-->

# keyboardSetUnicodeString(stringLength:unicodeString:)

Sets the Unicode string associated with a Quartz keyboard event.

```
func keyboardSetUnicodeString(stringLength: Int, unicodeString: UnsafePointer<UniChar>?)
```

## Parameters

`stringLength`

The length of the array you provide in the `unicodeString` parameter.

`unicodeString`

An array that contains the new Unicode string associated with the specified event.

## Discussion

By default, the system translates the virtual key code in a keyboard event into a Unicode string based on the keyboard ID in the event source. This function allows you to manually override this string. Note that application frameworks may ignore the Unicode string in a keyboard event and do their own translation based on the virtual keycode and perceived event state.

---

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)