我有处理程序:
myObj[id] = new google.maps.Circle({/*Initialization*/}
myObj[id].addListener('click', function (event) {
//Some code here
myFunction(this, event);
}
并且功能不起作用。
myFunction(elem, event) {
console.log(event);
if(!event.shiftKey) { //Do Something }
}
从下图中可以看出,qZ
对象有Aa
属性?,它负责MouseEvents
,对吧?
{{3}}
好吧,如果我将我的功能改为:
myFunction(elem, event) {
if(!event.Aa.shiftKey) { //Do Something }
}
有效。问题是,此Aa
曾经是Va
和Xa
。我无法一直保持chaning。我不知道为什么会这样,也不知道怎么解决它。
它检测到click
正在正常调用函数,但忽略了shiftKey。我怎样才能检测到shiftKey
click
事件的shiftKey
?
根据Dan给出的提示,我尝试循环访问该对象并尝试找到var shiftKey;
if (Object.keys(event).some(function (key) {
if (event[key] && 'shiftKey' in event[key]) {
shiftKey = event[key].shiftKey;
return true;
}
return false;
})) {
// We found it, `shiftKey` has the value. Do nothing
} else {
//If no shiftKey is pressed execute my code!
}
:
for Codeigniter 3.1.4
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php5_module>
php_flag asp_tags On
php_flag display_errors On
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 512M
php_value post_max_size 128M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
php_value upload_max_filesize 128M
php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
但是现在它永远不会执行我的代码,当没有按下shiftKey时应该触发...
答案 0 :(得分:0)
从你的更新中我看到一个错误:
var shiftKey;
if (Object.keys(event).some(function (key) {
if (event[key] && 'shiftKey' in event[key]) {
shiftKey = event[key].shiftKey;
return true; // <- should be return shiftKey
}
return false;
})) {
// We found it, `shiftKey` has the value. Do nothing
} else {
//If no shiftKey is pressed execute my code!
}