<!--
{
  "documentType" : "article",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/movement-codes",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Movement Codes"
}
-->

# Movement Codes

The reason for a change of editing focus among text fields.

## Discussion

These constants are the possible values for the `NSTextMovement` key of the [`didEndEditingNotification`](/documentation/AppKit/NSText/didEndEditingNotification) `userInfo` dictionary. The field editor makes sure that these are the values sent when the user presses the Tab, Backtab, or Return key while editing, in essence describing why the user is leaving the field. The control then uses this information to decide where to send focus next.

## Topics

### Constants

[`var NSIllegalTextMovement: Int`](/documentation/AppKit/NSIllegalTextMovement)

Currently unused.

[`var NSReturnTextMovement: Int`](/documentation/AppKit/NSReturnTextMovement)

The Return key was pressed.

[`var NSTabTextMovement: Int`](/documentation/AppKit/NSTabTextMovement)

The Tab key was pressed.

[`var NSBacktabTextMovement: Int`](/documentation/AppKit/NSBacktabTextMovement)

The Backtab (Shift-Tab) key was pressed.

[`var NSLeftTextMovement: Int`](/documentation/AppKit/NSLeftTextMovement)

The left arrow key was pressed.

[`var NSRightTextMovement: Int`](/documentation/AppKit/NSRightTextMovement)

The right arrow key was pressed.

[`var NSUpTextMovement: Int`](/documentation/AppKit/NSUpTextMovement)

The up arrow key was pressed.

[`var NSDownTextMovement: Int`](/documentation/AppKit/NSDownTextMovement)

The down arrow key was pressed.

[`var NSCancelTextMovement: Int`](/documentation/AppKit/NSCancelTextMovement)

The user cancelled the completion.

[`var NSOtherTextMovement: Int`](/documentation/AppKit/NSOtherTextMovement)

The user performed some undefined action.



---

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)