Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I handle ESC key in Cocoa app?

Tags:

I made an app switching to full screen mode. I want to use ESC key to escaping fullscreen mode, but binding menu item to ESC key in IB is removed at runtime. How can I keep ESC key binding to a menu item?

like image 538
eonil Avatar asked May 13 '11 15:05

eonil


People also ask

What can I use instead of Esc key?

Avoiding the Esc key If you have an American English keyboard, pressing Ctrl-[ (control plus left square bracket) is equivalent to pressing Esc.

How do I use Esc key?

True to its name, the Esc key acts like a “Cancel” button on most computers. On Windows, for example, the key can be used to close a dialog box without having to click “Cancel” with a mouse button. You can also use the Esc key to cancel loading a website in a browser.

What is the command for Esc?

On computer keyboards, the Esc key Esc (named Escape key in the international standard series ISO/IEC 9995) is a key used to generate the escape character (which can be represented as ASCII code 27 in decimal, Unicode U+001B, or Ctrl + [ ).


1 Answers

Preferred way to handle escape key in Cocoa is this as like @Josh Caswell said.

#pragma mark - NSResponder - (void)cancelOperation:(id)sender {     [self exitFullScreen]; } 
like image 178
eonil Avatar answered Nov 24 '22 08:11

eonil