initial
[lua-termkey.git] / demo.lua
blob241a83c9b435cfd87f8738064038295342256d29
1 local termkey = require('termkey')
2 local inspect = require('inspect')
4 local tk = termkey.new({ spacesymbol = true, ctrlc = true })
6 if not tk then
7 print('Cannot allocate termkey instance')
8 return
9 end
11 if tk:get_flags()["utf8"] then
12 print('Termkey in UTF-8 mode')
13 elseif tk:getflags()["raw"] then
14 print('Termkey in RAW mode')
15 end
17 print('\027[?1000h')
19 local k = tk:waitkey()
20 while k ~= "eof" and k ~= "error" do
21 print(inspect(k))
23 if k.ctrl and (k.utf8 == "c" or k.utf8 == "C") then
24 return
25 elseif not (k.ctrl or k.shift or k.alt) and k.utf8 == "?" then
26 print("\027[?1$p")
27 end
29 k = tk:waitkey()
30 end