mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Handle arrow keys and enter in emulator text fields
This commit is contained in:
@@ -543,30 +543,47 @@ end
|
||||
-- is shown. Mostly likely to be in the emulator, but could be Android + BT
|
||||
-- keyboard, or a "coder's keyboard" Android input method.
|
||||
function InputText:onKeyPress(key)
|
||||
if key["Backspace"] then
|
||||
self:delChar()
|
||||
elseif key["Del"] then
|
||||
self:rightChar()
|
||||
self:delChar()
|
||||
elseif key["Left"] then
|
||||
self:leftChar()
|
||||
elseif key["Right"] then
|
||||
self:rightChar()
|
||||
elseif key["End"] then
|
||||
self:goToEnd()
|
||||
elseif key["Home"] then
|
||||
self:goToHome()
|
||||
|
||||
local handled = true
|
||||
|
||||
if not key["Ctrl"] and not key["Shift"] and not key["Alt"] then
|
||||
if key["Backspace"] then
|
||||
self:delChar()
|
||||
elseif key["Del"] then
|
||||
self:rightChar()
|
||||
self:delChar()
|
||||
elseif key["Left"] then
|
||||
self:leftChar()
|
||||
elseif key["Right"] then
|
||||
self:rightChar()
|
||||
elseif key["Up"] then
|
||||
self:upLine()
|
||||
elseif key["Down"] then
|
||||
self:downLine()
|
||||
elseif key["End"] then
|
||||
self:goToEnd()
|
||||
elseif key["Home"] then
|
||||
self:goToHome()
|
||||
elseif key["Press"] then
|
||||
self:addChars("\n")
|
||||
elseif key["Tab"] then
|
||||
self:addChars(" ")
|
||||
else
|
||||
handled = false
|
||||
end
|
||||
elseif key["Ctrl"] and not key["Shift"] and not key["Alt"] then
|
||||
if key["U"] then
|
||||
self:delToStartOfLine()
|
||||
elseif key["H"] then
|
||||
self:delChar()
|
||||
else
|
||||
handled = false
|
||||
end
|
||||
else
|
||||
return false
|
||||
handled = false
|
||||
end
|
||||
|
||||
return true
|
||||
return handled
|
||||
end
|
||||
|
||||
-- Handle text coming directly as text from the Device layer (eg. soft keyboard
|
||||
|
||||
Reference in New Issue
Block a user