Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping keyboard shortcuts (ex copy / paste) to home row keys #9

Open
Qerlak opened this issue Jun 26, 2020 · 3 comments
Open

Mapping keyboard shortcuts (ex copy / paste) to home row keys #9

Qerlak opened this issue Jun 26, 2020 · 3 comments

Comments

@Qerlak
Copy link

Qerlak commented Jun 26, 2020

Hey svenlr!

Just started playing around in Linux today, and found your python script, and I was trying to figure out how to get keyboard shortcuts to work (like Ctrl + X for cut, Ctrl + C for copy, etc) when I held CapsLock down and pressed keys on my home row. My ideal setup would be "Caps + s" for cut, "Caps + d" for copy, and "Caps + f" for paste. I figured out how to get the keycodes for s, d, and f, (39, 40, and 41 respectively), but I'm not sure how to code the "mapped_sequence" to get the combination of ctrl and the respective key pressed simultaneously to cut/copy/paste content.

Cheers.

@svenlr
Copy link
Owner

svenlr commented Jun 29, 2020

Hi Querlak,
Please pull on master branch and then, copy the JSON below into your config.json. I tested it locally on my laptop and it works as you described.
(python-xlib is required for this solution).

      {
        "key_code": 39,
        "mapped_sequences": {
          "down": [
            {
              "key": "x",
              "modifiers": "Control"
            }
          ]
        }
      },
      {
        "key_code": 40,
        "mapped_sequences": {
          "down": [
            {
              "key": "c",
              "modifiers": "Control"
            }
          ]
        }
      },
      {
        "key_code": 41,
        "mapped_sequences": {
          "down": [
            {
              "key": "v",
              "modifiers": "Control"
            }
          ]
        }
      },

Cheers

@talenelat-elin
Copy link

Hi svenlr,

I have two questions related to this issue:

  1. Is it possible to map keyboard shortcuts of non-alphanumeric keys? For example I wanted to map CapsLock + m and CapsLock + . to Ctrl + LEFT and Ctrl + RIGHT respectively. I tried this snippet and it doesn't seem to work:
      {
        "key_code": 58,
        "mapped_sequences": {
          "down": [
            {
              "mapped_key_label": "LEFT",
              "modifiers": "Control"
            }
          ]
        }
      },
      {
        "key_code": 60,
        "mapped_sequences": {
          "down": [
            {
              "mapped_key_label": "RGHT",
              "modifiers": "Control"
            }
          ]
        }
      },
  1. Is it possible to add multiple modifiers shortcuts to keys? For example, how do I map "Ctrl + Alt + Shift + a"?

I've been trying to create Home-Row-Computing-Extended in Linux, this and this has turned to be the best solution, so thanks for creating it!

@talenelat-elin
Copy link

talenelat-elin commented Feb 21, 2023

As it often happens, I figured out 1. right after posting the issue:

      {
        "key_code": 58,
        "mapped_sequences": {
          "down": [
            {
              "key": "Left",
              "modifiers": "Control"
            }
          ]
        }
      },

EDIT: I figured out both of them. Sorry for the spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants