我有一個HTML表單,特別是在iOS上,我需要防止用戶在模式出現時通過輸入「掛鉤」。如何防止iOS uikeyboard箭頭觸發「標籤」動作?
因爲iOS鍵盤沒有標準的tab
鍵,所以我在引用「tabbing」時使用了鍵盤,它使用鍵盤上方工具欄中的上一個/下一個箭頭。 (見下圖)
有連接到這些按鍵沒有DOM事件,所以在閱讀和e.keyCode
使用e.preventDefault()
不是選項。有任何想法嗎?
我有一個HTML表單,特別是在iOS上,我需要防止用戶在模式出現時通過輸入「掛鉤」。如何防止iOS uikeyboard箭頭觸發「標籤」動作?
因爲iOS鍵盤沒有標準的tab
鍵,所以我在引用「tabbing」時使用了鍵盤,它使用鍵盤上方工具欄中的上一個/下一個箭頭。 (見下圖)
有連接到這些按鍵沒有DOM事件,所以在閱讀和e.keyCode
使用e.preventDefault()
不是選項。有任何想法嗎?
我最終實施的解決方案是類似以下內容:
HTML
<!-- modal content -->
<div class="search-modal">
<input type="search" id="search-input" />
<input type="text" onfocus="refocus('search-input')" style="opacity:0;" />
</div>
<!-- main page content -->
<div class="page-body">
<input type="text" name="fname" />
<input type="text" name="lname" />
<input type="email" name="email" />
<input type="tel" name="phone" />
<!-- ... -->
</div>
JS
function refocus(id){
document.getElementById(id).focus();
}
無論何時使用 「下一個」 箭頭,無形輸入收益重點。它立即將焦點重新放回原始輸入;從而防止非模態輸入獲得重點。
'$(document).bind('keydown',...)','mousedown','touchstart'?有些事件被解僱了? – spirit
@spirit nope,就像我在帖子中所說的,這些箭頭不會觸發任何DOM事件。 – SteamDev