i am working on a transliteration app that gets some text from an NSTextView and transliterate it and puts it in another NSTextView, what i want to do is, as the user is typing the sentence when he types a word and presses space i want the space key to trigger an action which i specify to break the sentence into an array of individual words. in order to do that i have tried overriding the keyDown function in the viewController class:
override func keyDown(theEvent: NSEvent) {
if (theEvent.keyCode == 49){
print("pressed space")
}
}
which does not work , it works when i subclass NSTextView class and override keyDown function in it but my textView stops inputing text. how can i set a key event for space key that works ? any other suggestion for breaking a sentence into word array by pressing space?
thanks