ユーザーが「Escape」キーを押したときに更新イベントを発生させたい、または Esc キーを押したときに画像クリック イベントを発生させたい これを達成する最善の方法は何ですか? ありがとう
$clone.click(function (e) { //action when magnified image is clicked on
var $this = $(this)
var imageinfo = $this.data('$relatedtarget').data('imgshell')
jQuery.imageMagnify.refreshoffsets($(window), $this.data('$relatedtarget'), imageinfo) //refresh offset positions of original and warped images
$this.stop().animate({ opacity: 0, left: imageinfo.attrs.x, top: imageinfo.attrs.y, width: imageinfo.attrs.w, height: imageinfo.attrs.h }, setting.duration,
function () {
$this.hide()
$this.data('$relatedtarget').css({ opacity: 1 }) //reveal original image
}) //end animate
}) //end click
//This is what I put in, but I'd like it to not just refresh but actually perform the same function as OnClick as above
$(document).keyup(function (e) { //action when magnified image is clicked on
if (e.keyCode == 27) { //escape key
window.location.reload();
}
}) //end click
$clone.keyup(function (e) { //action when 'Esc' key is pressed after magnifying image
if (e.keyCode == 27) { //escape key
var $this = $(this)
var imageinfo = $this.data('$relatedtarget').data('imgshell')
jQuery.imageMagnify.refreshoffsets($(window), $this.data('$relatedtarget'), imageinfo) //refresh offset positions of original and warped images
$this.stop().animate({ opacity: 0, left: imageinfo.attrs.x, top: imageinfo.attrs.y, width: imageinfo.attrs.w, height: imageinfo.attrs.h }, setting.duration,
function () {
$this.hide()
$this.data('$relatedtarget').css({ opacity: 1 }) //reveal original image
}) //end animate
}
}) //end
}
};