Ask coding questions

← Back to all posts
keypress in swift
JacobMcPherson1 (191)

How do you detect user keydown in swift?
I know how to do it in C# and python but i cant figure it out for swift

InvisibleOne (2678)

Something like this I believe, it's been a while since I've used swift for anything

override func keyDown(theEvent: NSEvent!)
    if theEvent.keyCode == blablabla
        key_pressed = 'bla bla bla'
    println("Key with number: \(theEvent.keyCode) was pressed")