on.keychord_press = function(chord, key) if chord == 'C-n' then animate(new) elseif chord == '`' then if Draw == 'problem' then Draw = 'solution' elseif Draw == 'solution' then Draw = 'problem' end elseif chord:match('%d') then -- cursor visible local x,y = Cursor[1], Cursor[2] if x > 0 and y > 0 then -- it's not in the provided square if x ~= Problem.x or y ~= Problem.y then local c = Problem.data[y][x] local d = (string.byte(chord) - 48) if c == '' then c = 0 end if c < 2 then -- not overfull Problem.data[y][x] = c*10 + d end end end elseif chord == 'backspace' then -- cursor visible local x,y = Cursor[1], Cursor[2] if x > 0 and y > 0 then -- it's not in the provided square if x ~= Problem.x or y ~= Problem.y then local c = Problem.data[y][x] if c ~= '' then Problem.data[y][x] = math.floor(c/10) if Problem.data[y][x] == 0 then Problem.data[y][x] = '' end end end end end end