The statement about <key> elements requiring either the command attribute or oncommand is correct. Considering the code that runs the key handlers , it has an optimization that will ignore any <key> element that is either disabled or has neither the command nor the oncommand attribute, so the command event will not fire for these elements. I solve this by adding the oncommand attribute of the dummy text containing the JavaScript comment:
key.setAttribute("oncommand", "//");
But void(0); great as attribute value, of course.
There will be no problem considering this. The potential security issue you heard about generates a dynamic oncommand value, for example:
key.setAttribute("oncommand", "foo('" + bar + "')");
Depending on the value of bar (and especially when bar comes from a website) this can be very dangerous. However, you do not generate the attribute value dynamically; it is always void(0); in your case - so there are no problems.
source share