diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index c5f8ad531..dcf1cb456 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -105,6 +105,13 @@ function DictQuickLookup:init() self.key_events.ReadNextResult = { { Input.group.PgFwd } } self.key_events.Close = { { Input.group.Back } } self.key_events.ShowResultsMenu = { { "Menu" } } + if Device:hasKeyboard() then + self.key_events.ChangeToPrevDict = { { "Shift", "Left" } } + self.key_events.ChangeToNextDict = { { "Shift", "Right" } } + elseif Device:hasScreenKB() then + self.key_events.ChangeToPrevDict = { { "ScreenKB", "Left" } } + self.key_events.ChangeToNextDict = { { "ScreenKB", "Right" } } + end end if Device:isTouchDevice() then local range = Geom:new{ @@ -424,7 +431,7 @@ function DictQuickLookup:init() vsync = true, enabled = self:isPrevDictAvaiable(), callback = function() - self:changeToPrevDict() + self:onChangeToPrevDict() end, hold_callback = function() self:changeToFirstDict() @@ -448,7 +455,7 @@ function DictQuickLookup:init() vsync = true, enabled = self:isNextDictAvaiable(), callback = function() - self:changeToNextDict() + self:onChangeToNextDict() end, hold_callback = function() self:changeToLastDict() @@ -957,7 +964,7 @@ function DictQuickLookup:isNextDictAvaiable() return self.dict_index < #self.results end -function DictQuickLookup:changeToPrevDict() +function DictQuickLookup:onChangeToPrevDict() if self:isPrevDictAvaiable() then self:changeDictionary(self.dict_index - 1) elseif #self.results > 1 then -- restart at end if first reached @@ -965,7 +972,7 @@ function DictQuickLookup:changeToPrevDict() end end -function DictQuickLookup:changeToNextDict() +function DictQuickLookup:onChangeToNextDict() if self:isNextDictAvaiable() then self:changeDictionary(self.dict_index + 1) elseif #self.results > 1 then -- restart at first if end reached @@ -1076,13 +1083,13 @@ end ]]-- function DictQuickLookup:onReadNextResult() - self:changeToNextDict() + self:onChangeToNextDict() return true end function DictQuickLookup:onReadPrevResult() local prev_index = self.dict_index - self:changeToPrevDict() + self:onChangeToPrevDict() if self.dict_index ~= prev_index then -- Jump directly to bottom of previous dict definition -- to keep "continuous reading with tap" consistent @@ -1162,9 +1169,9 @@ function DictQuickLookup:onSwipe(arg, ges) -- or not ges.pos:intersectWith(self.dict_frame.dimen) then local direction = BD.flipDirectionIfMirroredUILayout(ges.direction) if direction == "west" then - self:changeToNextDict() + self:onChangeToNextDict() elseif direction == "east" then - self:changeToPrevDict() + self:onChangeToPrevDict() else if self.refresh_callback then self.refresh_callback() end -- update footer (time & battery) diff --git a/frontend/ui/widget/inputtext.lua b/frontend/ui/widget/inputtext.lua index 334730b03..243aadfec 100644 --- a/frontend/ui/widget/inputtext.lua +++ b/frontend/ui/widget/inputtext.lua @@ -595,11 +595,16 @@ function InputText:onKeyPress(key) end local handled = true - if not key["Ctrl"] and not key["Shift"] and not key["Alt"] then + if not key["Ctrl"] and not key["Shift"] and not key["Alt"] and not key["ScreenKB"] then if key["Backspace"] then self:delChar() elseif key["Del"] then - self:delNextChar() + -- Kindles with physical keyboards only have a "Del" key (no "Backspace"). + if Device:hasSymKey() then + self:delChar() + else + self:delNextChar() + end elseif key["Left"] then self:leftChar() elseif key["Right"] then @@ -634,6 +639,31 @@ function InputText:onKeyPress(key) else handled = false end + if not handled and (key["ScreenKB"] or key["Shift"]) then + handled = true + if key["Back"] then + 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["Home"] then + if self.keyboard:isVisible() then + self:onCloseKeyboard() + else + self:onShowKeyboard() + end + elseif key["."] and Device:hasSymKey() then + -- Kindle does not have a dedicated button for commas + self:addChars(",") + else + handled = false + end + end if not handled and Device:hasDPad() then -- FocusManager may turn on alternative key maps. -- These key map maybe single text keys.