- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将我的 CAPSLOCK 绑定(bind)到 F18(karabiner)作为修饰键。我正在尝试模拟 CAPSLOCK+h、j、k、l 来充当 VIM 移动键。一切正常,但重复时存在延迟问题。也就是说,当我按下 CAPSLOCK+h 时它非常慢,它应该模拟反复按下“<-”键,但它非常延迟并且每秒只发送一个。关于为什么会发生这种情况的任何想法?我的 init.lua
在下面:
-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")
-- Enter Hyper Mode when F18 (Hyper/Capslock) is pressed
pressedF18 = function()
k.triggered = false
k.modifier = false
k:enter()
trigger_modifier = function()
k.modifier = true
end
-- Only trigger as modifier if held longer than thisj
hs.timer.doAfter(0.35, trigger_modifier)
end
-- Arrow keys
k:bind({}, 'h', function()
hs.eventtap.keyStroke({}, 'Left')
k.triggered = true
end)
k:bind({}, 'j', function()
hs.eventtap.keyStroke({}, 'Down')
k.triggered = true
end)
k:bind({}, 'k', function()
hs.eventtap.keyStroke({}, 'Up')
k.triggered = true
end)
k:bind({}, 'l', function()
hs.eventtap.keyStroke({}, 'Right')
k.triggered = true
end)
-- Leave Hyper Mode when F18 (Hyper/Capslock) is pressed,
-- send ESCAPE if no other keys are pressed.
releasedF18 = function()
k:exit()
if not k.triggered then
-- If hotkey held longer than this amount of time
-- let it remain as modifier and don't send ESCAPE
if not k.modifier then
hs.eventtap.keyStroke({}, 'ESCAPE')
else
print("Modifier detected")
end
end
end
-- Bind the Hyper key
f18 = hs.hotkey.bind({}, 'F18', pressedF18, releasedF18)
最佳答案
我有一些类似的缓慢。似乎在最新版本之一中引入了一些缓慢。您可以使用 fastKeyStroke
调用较低级别的函数下面的功能。我已经包含了我的 hjkl
实现,所以你可以看到它使用。另请注意,我将 5 个参数传递给 hs.hotkey.bind
如docs 中指定的用于键重复。
local hyper = {"shift", "cmd", "alt", "ctrl"}
local fastKeyStroke = function(modifiers, character)
local event = require("hs.eventtap").event
event.newKeyEvent(modifiers, string.lower(character), true):post()
event.newKeyEvent(modifiers, string.lower(character), false):post()
end
hs.fnutils.each({
-- Movement
{ key='h', mod={}, direction='left'},
{ key='j', mod={}, direction='down'},
{ key='k', mod={}, direction='up'},
{ key='l', mod={}, direction='right'},
{ key='n', mod={'cmd'}, direction='left'}, -- beginning of line
{ key='p', mod={'cmd'}, direction='right'}, -- end of line
{ key='m', mod={'alt'}, direction='left'}, -- back word
{ key='.', mod={'alt'}, direction='right'}, -- forward word
}, function(hotkey)
hs.hotkey.bind(hyper, hotkey.key,
function() fastKeyStroke(hotkey.mod, hotkey.direction) end,
nil,
function() fastKeyStroke(hotkey.mod, hotkey.direction) end
)
end
)
关于lua - 我的 Hammerspoon 脚本中的键重复延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40986242/
在工作中,我有一个 3 显示器设置。我想通过键绑定(bind)将当前应用程序移动到第二个或第三个监视器。怎么做? 最佳答案 我使用以下脚本在屏幕中循环聚焦窗口。 -- bind hotkey hs.h
我是 Lua 和 hammerspoon 的新手,我一辈子都弄不明白为什么下面的代码在我的主屏幕上运行良好,但在我的辅助显示器上循环切换位置却不起作用。在辅助显示器上点击窗口上的快捷方式可启用第一个位
我在文档中找不到它 - 如何在 OS X 上使用 Hammerspoon 粘贴文本? 我尝试了以下方法: hs.hotkey.bind({"ctrl", "pad1"}, "1", function(
我想在我的 Hammerspoon 配置文件中使用更复杂的图形或 GUI 小部件库,以便获得用户输入并在屏幕上进行比 Hammerspoon 默认允许(据我所知)更高级的绘图。我是 Lua 和 Ham
好的,所以我有一个带有 Hammerspoon 的脚本,可以为我执行按键操作。简单的例子: hs.hotkey.bind({'cmd','alt','ctrl'}, "b", function()
要绑定(bind)到我使用的 1 键: hs.hotkey.bind(hyper, '1' 如何绑定(bind)1个键的多次按下?就像是: hs.hotkey.bind(hyper, '1+1' 阅读
我将我的 CAPSLOCK 绑定(bind)到 F18(karabiner)作为修饰键。我正在尝试模拟 CAPSLOCK+h、j、k、l 来充当 VIM 移动键。一切正常,但重复时存在延迟问题。也就是
我想使用键盘快捷键在 Hammerspoon 上打开一个目录。要通过快捷方式打开任何应用,请使用以下命令: hs.hotkey.bind({"ctrl"}, "n", function() h
用户切换焦点后我可以通过以下代码获取应用名称: function applicationWatcher(appName, eventType, appObject) if (eventType =
我正在尝试创建一个快捷方式,通过使用 hs.chooser 来存储一组文本模板。并且,用户可以通过单击 hs.chooser 的下拉菜单来粘贴它。 我使用下面的代码来显示我的模板但不粘贴文本。 谁能指
我使用名为 hammerspoon 的自动化软件在 osx 上。 当我在hammerspoon 的控制台中使用以下代码时,win为零: > local win = hs.window.focusedW
我想分开init.lua Hammerspoon 中用于增强可读性和可维护性的脚本。 所以它看起来像下面这样: 初始化.lua AppWatcher.lua WiFiWatcher.lua KeyRe
我刚开始使用Hammerspoon .我试图通过按 Cmd+Shift+l 输出多行文本。 这是我迄今为止尝试过的: hs.hotkey.bind({"cmd", "shift"}, "l", fun
我是一名优秀的程序员,十分优秀!