O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

NSEvent

We discussed NSEvent in terms of mouse events in the previous chapter. Here are some of the properties commonly used when getting information about a keyboard event:

v​a​r​ ​c​h​a​r​a​c​t​e​r​s​:​ ​S​t​r​i​n​g​!​ ​{​ ​g​e​t​ ​}​

Returns the characters created by the event.

v​a​r​ ​A​R​e​p​e​a​t​:​ ​B​o​o​l​ ​{​ ​g​e​t​ ​}​

true if the key event is a repeat caused by the user holding the key down; false if the key event is new.

v​a​r​ ​k​e​y​C​o​d​e​:​ ​U​I​n​t​1​6​ ​{​ ​g​e​t​ ​}​

Returns the code for the keyboard key that caused the event.

v​a​r​ ​m​o​d​i​f​i​e​r​F​l​a​g​s​:​ ​N​S​E​v​e​n​t​M​o​d​i​f​i​e​r​F​l​a​g​s​ ​{​ ​g​e​t​ ​}​

Returns an integer bit field indicating the modifier keys in effect ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required