0
ユーザーががを入力しクリックしたときにシフトが押された場合は、新しいウィンドウを開こうとイム、と彼らはCTRLをヒットした場合、新しいタブ。 シフト一部の作品が、CTRL一部にはない...私のコードがCtrlキーの状態を検出できないのはなぜですか?
var ctrlPressed = false;
var shiftPressed = false;
var stb = null;
function onload() {
stb = document.getElementById("searchTextBox");
}
function enter(e) {
if (e.keyCode == 13) {
if (!ctrlPressed && !shiftPressed) {
window.location = "http://search.yahoo.com/search?p=" + encodeURI(stb.value) + "&fr2=sb-top&fr=404_web&pqstr=" + encodeURI(stb.value);
}
else if (ctrlPressed) {
window.open("http://search.yahoo.com/search?p=" + encodeURI(stb.value) + "&fr2=sb-top&fr=404_web&pqstr=" + encodeURI(stb.value));
}
else if (shiftPressed) {
window.open("http://search.yahoo.com/search?p=" + encodeURI(stb.value) + "&fr2=sb-top&fr=404_web&pqstr=" + encodeURI(stb.value), "_blank");
}
}
}
function searchdown(e) {
if (e.keyCode == 17) {
ctrlPressed = true;
}
else if (e.keyCode == 16) {
shiftPressed = true;
}
}
function searchup(e) {
if (e.keyCode == 17) {
ctrlPressed = false;
}
else if (e.keyCode == 16) {
shiftPressed = false;
}
}
は、[編集]また、私はjqueryの
イベントの委任はどこですか? –