How to detect Ctrl+S being pressed?


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"/>

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?


Hi Fabian,

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


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.

Please sign in to leave a comment.