Sublime Forum

[SOLVED] How to get the last key that user pressed?

#1

It sounds like a python question rather than a ST one, but the answer I found gave me module not found for termios.
The actual problem I encountered is described below.

There is a plugin that if users type 'vv ', it converts 'vv ’ into ‘$’.
The question is that it uses on_modified() to trigger this conversion without any other condition.
It breaks the functionality of Ctrl+Z(undo).
If I press Ctrl+Z, the ‘$’ is modified back to 'vv ’ and this triggers the conversion again so actually nothing happens after pressing Ctrl+Z.
I am thinking that checking the last key pressed to fix this.


Update.
I have got an alternative solution for checking.

        istoryCmd = view.command_history(1)
        if historyCmd[0] == 'THE_PLUGIN_COMMAND':
            return
0 Likes