How to assign escape as a key equivalent to a button in swift?

I have working code in the c object class that looks like this:

closeButton.keyEquivalent = @"\e"; 

This does not work fast because it says: "Invalid escape sequence in literal." I tried using the following code:

 closeButton.keyEquivalent = "\u{53}" 

But no luck. Any ideas?

+7
swift
source share
1 answer

You need to assign

 closeButton.keyEquivalent = "\u{1b}" 

Just tried in a test application.

Change According to @Lucasware comment, ObjC appointment

 [NSString stringWithFormat:@"%C", 0x1b] 
+16
source share

All Articles