-
Notifications
You must be signed in to change notification settings - Fork 0
/
swap-bracket-brace.lua
78 lines (60 loc) · 2.27 KB
/
swap-bracket-brace.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
-- module.eventwatcher3 = hs.eventtap.new({"all"}, function(e)
-- local keyCode = e:getKeyCode()
-- local flags = e:getFlags()
-- local type = e:getType()
-- -- hs.eventtap.event.types.keyUp
-- if not flags.shift then
-- if keyCode == 33 then
-- print("[")
-- -- fastKeyStroke({"shift"}, "[")
-- -- return true
-- elseif keyCode == 30 then
-- print("]")
-- -- fastKeyStroke({}, "{")
-- -- return true
-- end
-- else
-- print("hello")
-- end
-- end):start()
-------------------------------------------------------------------------------
-- DISABLED: Use custom keyboard with Ukelele.
-- -- Swap brackets and braces.
-- -- TODO(vjpr): Make everything use this module namespace.
-- swapBracketAndBracesModule = {}
-- -- local trigger = function()
-- -- end
-- -- TODO(vjpr): Set properties.
-- local swapBracketsAndBraces = function(e)
-- local event = require("hs.eventtap").event
-- local keyCode = e:getKeyCode()
-- local isDown = e:getType() == hs.eventtap.event.types.keyDown
-- local flags = e:getFlags()
-- print("data", hs.inspect(e:getRawEventData()))
-- if keyCode == 0x21 then
-- print("opening bracket/brace key")
-- if (flags.shift) then
-- event.newKeyEvent({}, string.lower("["), isDown):post()
-- else
-- event.newKeyEvent({"shift"}, string.lower("["), isDown):post()
-- end
-- return true
-- elseif keyCode == 0x1e then
-- print("closing bracket/brace key")
-- if (flags.shift) then
-- event.newKeyEvent({}, string.lower("]"), isDown):post()
-- else
-- event.newKeyEvent({"shift"}, string.lower("]"), isDown):post()
-- end
-- return true
-- end
-- return false
-- end
-------------------------------------------------------------------------------
-- hs.hotkey.bind({}, string.lower("["), nil, function() hs.eventtap.keyStroke({"shift"}, string.lower("[")) end
--------------------------------------------------------------------------------
-- hs.eventtap.new({hs.eventtap.event.types.keyUp, hs.eventtap.event.types.keyDown}, function(e)
-- -- print(e:getKeyCode(), e:getType(), hs.inspect(e:getFlags()))
-- -- TODO(vjpr): Not working. Using a custom keyboard layout instead.
-- -- return swapBracketsAndBraces(e)
-- end):start()