How to detect Ctrl+S being pressed?

Answered

I have a requirement to perform an action on Ctrl+S. I tried to declare the action and the short cut in my plugin.xml but since this shortcut is already used by `SaveAll` it does not work.

      <action id="myActionID" class="com.example.myClass"description="bla">
        <keyboard-shortcut keymap="$default" first-keystroke="ctrl shift S" replace-all="true"/>
      </action>

Note that I don't want to perform this action when the files are saved (I am aware of ways to listen for this event), I really want to detect Ctrl+S. Is there a way to do this?

2 comments
Comment actions Permalink

Hi Fabian,

Overriding the core IDE functionality shortcut doesn't sound like a good idea. What is your use case?

0
Comment actions Permalink

I found out how to do it, so here it is for future programmers.

  1. Use a AnActionListener.
  2. There is a call back there that is invoked every time a shortcut is detected.
  3. You can compare the Shortcut with anything, including Ctrl+S.
0

Please sign in to leave a comment.