1

I would like to know how to detect if a key is pressed in iOS.

I was looking for answers over other pages but the answers I found are in Objective-C and 4 years old or more.

What I tried is:

override func keyDown(event: NSEvent) {
    super.keyDown(event)
    Swift.print("Caught a key down: \(event.keyCode)!")
}

but then I realized that this code is on desktop.

And I found this:

func keyDown(with event: NSEvent)

but do I have to inherit from some class?

rmaddy
  • 314,917
  • 42
  • 532
  • 579

0 Answers0