Forum Archive

[SOLVED] Is there anyway to capture the input from keyboard?

goldenretrieume

THIS QUESTION HAS BEEN SOLVED

I want to capture all input from keyboard (including SHIFH, ALT, COMMAND and ARROW keys) in my app. Is there anyway to achieve this goal?

My first idea is that putting invisible ui.TextView and move focus onto it, then watch the ui.TextView's buffer. Most input can get with this idea, but I cant capture special keys like SHIFT, CTRL, ALT and ARROW keys.

JonB

Using objc you can.

See ShTerminal in shterminal.py in stash for a good example of this, which uses modifier keys, etc.

Otherwise search the forums for keyCommands

You can attach the callback to any UIResponder, which could be the main app, a textview, or any other general view.

goldenretrieume

@JonB Thanks a lot for your quick suggestion! I'll read them and try.

goldenretrieume

This question has been solved here. Thanks @JonB for giving me very helpful hint ☺️