handle chords

[?]
May 2, 2022, 3:20 PM
6LJZN727CRPYR34LV75CQF55YZI3E7MGESYZSFSYAE73SNEZE3FAC

Dependencies

Change contents

  • edit in main.lua at line 1
    [3.2]
    [3.3]
    require 'keychord'
  • replacement in main.lua at line 30
    [3.451][3.451:527]()
    function love.keypressed(key, scancode, isrepeat)
    if key == 'return' then
    [3.451]
    [3.527]
    function love.textinput(t)
    lines[#lines] = lines[#lines]..t
    end
    function keychord_pressed(chord)
    -- Don't handle any keys here that would trigger love.textinput above.
    if chord == 'return' then
  • replacement in main.lua at line 38
    [3.555][3.2:70](),[3.70][3.2:112](),[3.112][2.2:69](),[2.69][3.112:207](),[3.112][3.112:207](),[3.207][2.70:175](),[3.70][3.555:601](),[2.175][3.555:601](),[3.249][3.555:601](),[3.555][3.555:601]()
    elseif key == 'space' then
    lines[#lines] = lines[#lines]..' '
    elseif key == 'lctrl' or key == 'rctrl' then
    -- do nothing
    elseif key == 'lalt' or key == 'ralt' then
    -- do nothing
    elseif key == 'lshift' or key == 'rshift' then
    -- do nothing
    elseif love.keyboard.isDown('lctrl') or love.keyboard.isDown('rctrl') then
    if key == 'r' then
    lines[#lines+1] = eval(lines[#lines])[1]
    lines[#lines+1] = ''
    end
    else
    lines[#lines] = lines[#lines]..key
    [3.555]
    [3.601]
    elseif chord == 'C-r' then
    lines[#lines+1] = eval(lines[#lines])[1]
    lines[#lines+1] = ''
  • edit in main.lua at line 42
    [3.607]
    [3.607]
    end
    function love.keyreleased(key, scancode)
    end
    function love.mousepressed(x, y, button)
  • edit in main.lua at line 50
    [3.612]
    [2.176]
    function love.mousereleased(x, y, button)
    end
  • edit in main.lua at line 75
    [2.679][2.679:684](),[2.684][3.612:653](),[3.612][3.612:653]()
    end
    function love.keyreleased(key, scancode)
  • edit in main.lua at line 76
    [3.657][3.657:750]()
    function love.mousepressed(x, y, button)
    end
    function love.mousereleased(x, y, button)
    end
  • file addition: keychord.lua (----------)
    [8.2]
    -- Keyboard driver
    function love.keypressed(key, scancode, isrepeat)
    if key == 'lctrl' or key == 'rctrl' or key == 'lalt' or key == 'ralt' or key == 'lshift' or key == 'rshift' or key == 'lgui' or key == 'rgui' then
    -- do nothing when the modifier is pressed
    end
    -- include the modifier(s) when the non-modifer is pressed
    keychord_pressed(combine_modifiers(key))
    end
    function combine_modifiers(key)
    local result = ''
    local down = love.keyboard.isDown
    if down('lctrl') or down('rctrl') then
    result = result..'C-'
    end
    if down('lalt') or down('ralt') then
    result = result..'M-'
    end
    if down('lgui') or down('rgui') then
    result = result..'S-'
    end
    result = result..key
    return result
    end