Create custom keyboard shortcut in Ubuntu 17.10 / 18.04

Follow the steps below.

  1. Go to Settings -> Devices -> Keyboard.
  2. Scroll to bottom, and click the "+" (plus) sign.
  3. Enter the command and assign a shortcut key.

For those who can't manage to find the adequate Settings (Ubuntu 18.04 maybe?), run in a terminal:

gnome-control-center

...then follow the procedure that @opensas mentioned:

  1. Go to Settings -> Devices -> Keyboard.
  2. Scroll to bottom, and click the "+" (plus) sign.
  3. Enter the command and assign a shortcut key.