-2

I want to intercept/override tab pressed event and provide my custom behaviour.

Subash thapa
  • 47
  • 1
  • 4
  • please check this [link](https://stackoverflow.com/questions/1347779/how-to-navigate-through-textfields-next-done-buttons/1351090#1351090) – Chirag Shah Jan 08 '19 at 12:54
  • @chiragshah The question clearly states it's about external keyboard – mag_zbc Jan 08 '19 at 13:26
  • 1
    Thank you guys . My question was not clear in the beginning sorry for that. Issue is resolved now. Appreciate your help. – Subash thapa Jan 08 '19 at 13:36

1 Answers1

2

You can override keyCommands property of your UIResponder (UITextField, UITextView etc.). You will need to write your own subclass, because keyCommands cannot be assigned value since it's a get-only property

override var keyCommands: [UIKeyCommand]? 
{
    return [UIKeyCommand(input: "\t", modifierFlags: [], action: #selector(tabPressed))]
}

@objc func tabPressed() 
{
    // do stuff
}
mag_zbc
  • 6,801
  • 14
  • 40
  • 62