Skip to content

Any way to create a config for remap all cmd to ctrl? #3246

Answered by MuhammedZakir
AlgusDark asked this question in Q&A
Discussion options

You must be logged in to vote

Notes:

  1. You will have to disable "secure keyboard entry" for key remapping to work.
  2. Always save objects that you want to persist indefinitely in global variables or in local variables that are referenced by global variables. Otherwise, they will be garbage collected.
  3. You may move this to a module to cleanup the function/variable names.

This should work:

local eventtap = hs.eventtap
local eventTypes = eventtap.event.types
local keycodes = hs.keycodes.map
local windowFilter = hs.window.filter


local function cmd2CtrlEventHandler(event)
  local flags = event:getFlags()
  local keycode = event:getKeyCode()

  if flags.cmd then
    flags.cmd = false
    flags.ctrl = true
  end

  if keycode == 

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
1 reply
@AlgusDark
Comment options

Comment options

You must be logged in to vote
6 replies
@MuhammedZakir
Comment options

@AlgusDark
Comment options

@MuhammedZakir
Comment options

@MuhammedZakir
Comment options

@AlgusDark
Comment options

Answer selected by AlgusDark
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants