4

OS: Ubuntu 18.04

I just switched over to Linux and Autokey.

In Autokey, I would like use Alt+X to send the Alt+F4 key stroke. I like to use this key stroke to automatically close or exit the most active window or program in the foreground.

I have tried using send keys but instead of actually sending the key stroke it just sends text.

If there is no way to simulate the keystroke, is there a way to send a close active window command?

DK Bose
  • 44,553
Perry_M
  • 53

2 Answers2

3

If you install xdotool using sudo apt install xdotool, you can use it to simulate a lot of stuff.

Then, open Settings > Devices > Keyboard and click on the + sign at the bottom to add a new shortcut.

  • Enter a name for your new shortcut such as Alt Close
  • Enter xdotool key Alt+F4 as the command
  • Press Alt+X as your choice for running the command.
DK Bose
  • 44,553
1

In addition to the answer of DK Bose, and especially as you are a newer user, I would prefer to point you to a simpler method that is exposed in the default user interface and does not rely on a third tool.

  • Open "Settings", then locate "Devices" and "Keyboard" in the left bar. Alternatively, you may just type "keyboard", which will trigger a search and bring you to the Keyboard panel.
  • Under the section "Windows", you can change the keyboard combination for "Close window". Click the entry. A "Set shortcut" dialog appears. Press your new keyboard combination to set it.
vanadium
  • 97,564