<!--
{
  "availability" : [
    "iOS: 3.2.0 -",
    "iPadOS: 3.2.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIResponder/keyboardFrameEndUserInfoKey",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:@UIKeyboardFrameEndUserInfoKey"
  },
  "title" : "keyboardFrameEndUserInfoKey"
}
-->

# keyboardFrameEndUserInfoKey

A user info key to retrieve the keyboard’s frame at the end of its animation.

```
nonisolated class let keyboardFrameEndUserInfoKey: String
```

## Discussion

The value for this key is an <doc://com.apple.documentation/documentation/Foundation/NSValue> object that contains a <doc://com.apple.documentation/documentation/CoreFoundation/CGRect> for identifying the frame rectangle of the keyboard (in the screen’s coordinate space) after animating the keyboard. The frame rectangle reflects the current orientation of the device.

> Important:
> Instead of using this key to track the keyboard’s frame, consider using ``doc://com.apple.uikit/documentation/UIKit/UIKeyboardLayoutGuide``, which allows you to respond dynamically to keyboard movement in your app. For more information, see <doc://com.apple.uikit/documentation/UIKit/adjusting-your-layout-with-keyboard-layout-guide>.

The keyboard’s frame uses the screen’s coordinate space, which is different than the coordinate space of your views. Although they might sometimes match, such as when your app is full screen, they might be different when your app isn’t full screen in Split View, Slide Over, and Stage Manager. This means you need to account for this difference by converting the keyboard’s frame from the screen’s coordinate space to that of your views. The following code example shows how to convert from the screen’s coordinate space to your view’s coordinate space:

```swift
guard let userInfo = notification.userInfo else { return }

// In iOS 16.1 and later, the keyboard notification object is the screen the keyboard appears on.
guard let screen = notification.object as? UIScreen,
      // Get the keyboard’s frame at the end of its animation.
      let keyboardFrameEnd = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }

// Use that screen to get the coordinate space to convert from.
let fromCoordinateSpace = screen.coordinateSpace

// Get your view's coordinate space.
let toCoordinateSpace: UICoordinateSpace = view

// Convert the keyboard's frame from the screen's coordinate space to your view's coordinate space.
let convertedKeyboardFrameEnd = fromCoordinateSpace.convert(keyboardFrameEnd, to: toCoordinateSpace)
```

The keyboard might overlap only part of your view, so after you convert the frame to your view’s coordinate space, get the intersection of the keyboard’s frame and the view or window it overlaps. Getting the intersection allows you to work with only the portion of the keyboard that overlaps your view. You can use this value to offset your views or perform other necessary updates to your UI. The following code example shows how to offset the bottom of your view the appropriate distance in relation to the keyboard’s frame:

```swift
// Get the safe area insets when the keyboard is offscreen.
var bottomOffset = view.safeAreaInsets.bottom
    
// Get the intersection between the keyboard's frame and the view's bounds to work with the
// part of the keyboard that overlaps your view.
let viewIntersection = view.bounds.intersection(convertedKeyboardFrameEnd)
    
// Check whether the keyboard intersects your view before adjusting your offset.
if !viewIntersection.isEmpty {
        
    // Adjust the offset by the difference between the view's height and the height of the
    // intersection rectangle.
    bottomOffset = view.bounds.maxY - viewIntersection.minY
}

// Use the new offset to adjust your UI, for example by changing a layout guide, offsetting
// your view, changing a scroll inset, and so on. This example uses the new offset to update
// the value of an existing Auto Layout constraint on the view.
movingBottomConstraint.constant = bottomOffset
```

---

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)