2014-07-16 120 views

回答

0

「句柄」有點含糊......你想要完成什麼?
如果您針對特定需求調用正確的鍵盤,則不需要檢測任何按鈕。

僅當您的input標籤位於form元素內時,纔會顯示iOS鍵盤中的搜索按鈕。
例如:

// This will display a return button. 
<input id="textField" type="text"/> 

// This will display a search button. 
<form> 
    <input id="searchField" type="search"/> 
</form> 


在JavaScript中,你可以使用jQuery keypress事件一旦搜索按鈕被點擊觸發操作。例如:

$("#searchField").keypress(function() { 
    alert("Handler for .keypress() called."); 
}); 

你也可以「檢測」的鍵盤的「類型」,在「搜索」,像以下的情況下(但這是有點明顯...):

if ($("#searchField").attr("type") == "search") { 
    alert("This search field is of type 'search'."); 
} 


否則,你將需要實現本地代碼(意思是Cordova plug-in)來檢測當前顯示的鍵盤的類型和執行的操作,等...

相關問題