Composed Keys

Supporting composed keys

Some keyboards compose characters with two or more keys. In the Spanish keyboard, accented characters are produced with accent key+character. A special case is the back quote. If it is included in the keypairs, it will not be recognised by Textadept automatically.

The key sequence to produce ` is

65104
32

The workaround is to include the following code in .textadept/init.lua

local previous = nil
events.connect(events.KEYPRESS, function(code)
  local altcode = nil
  if code == 32 then
    altcode = previous == 65104 and string.byte('`') or nil
  end
  previous = code
  if altcode ~= nil then
    if textadept.editing.typeover_chars and
       textadept.editing.typeover_chars[altcode] and
       buffer.selection_start == buffer.selection_end and
       buffer.char_at[buffer.current_pos] == altcode then
      buffer:char_right()
      return true
    end
  end
end)

(c) Pedro A. Aranda -- paaguti@hotmail.com

Feel free to use it in your code, but ack would be appretiated ;-)


Edited on Friday, February 9th 2018 at 12:47 AM.