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

# keyboardGetUnicodeString(maxStringLength:actualStringLength:unicodeString:)

Returns the Unicode string associated with a Quartz keyboard event.

```
func keyboardGetUnicodeString(maxStringLength: Int, actualStringLength: UnsafeMutablePointer<Int>?, unicodeString: UnsafeMutablePointer<UniChar>?)
```

## Parameters

`maxStringLength`

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

`actualStringLength`

A pointer to a `UniCharCount` variable. On return, the variable contains the actual count of Unicode characters in the event data.

`unicodeString`

A pointer to a `UniChar` array. You are responsible for allocating storage for the array. On return, your array contains the Unicode string associated with the specified event.

## Discussion

When you call this function and specify a `NULL` string or a maximum string length of 0, the function still returns the actual count of Unicode characters in the event data.

---

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)