title: Check if the u key is pressed Swift Cocoa
body: <p>I'm trying to detect if the <code>U</code> key is pressed or not, and if it is it should <code>print("BUT...BUT..");</code> but I'm not sure how to check for different keys, as the documentation for key presses is quite bad.. I found an answer with keycodes but they only work for QWERTY keyboards</p>
  
  <p><em>viewcontroller.swift</em></p>
  
  <pre><code>override func viewDidLoad(){
      super.viewDidLoad();
      let f = Foo();
      f.doSonethimg();
  }
  
  override func keyDown(theEvent: NSEvent){
      let f = Foo();
      f.KeyDown(theEvent);
  }
  </code></pre>
  
  <p><em>Foo.swift</em></p>
  
  <pre><code>public func doSonething(){
      print("Hello from Dylib");
  }
  
  public func keyDown(event: NSEvent){
          if let keyString = theEvent.charactersIgnoringModifiers where keyString == "u" || keyString == "U" {
      Swift.print("BUT...BUT…")
  }
  }
  </code></pre>
  
  <p>How would I change the <code>keyDown</code> Function to respond to <code>U</code> and what is it's default key?</p>
  
  <p>I've looked at - <a href="https://stackoverflow.com/questions/28158964/detecting-key-press-event-in-swift">Detecting key press event in Swift</a> and <a href="https://superuser.com/questions/399430/mouse-button-and-keypress-counter-for-mac-os-x">https://superuser.com/questions/399430/mouse-button-and-keypress-counter-for-mac-os-x</a></p>
  
  <p>also see - <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/HandlingKeyEvents.html" rel="nofollow noreferrer">https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/HandlingKeyEvents.html</a> - Overriding the keyDown: Method</p>