Skip to content

Commit

Permalink
Customise Mousetrap library useCapture flag
Browse files Browse the repository at this point in the history
To be able to stop the propagation of events to the website but still
capture them in Vimary we need to listen to the keyEvents using the
onCapture flag. Something that has not yet been implemented in
Mousetrap (see ccampbell/mousetrap#400).
  • Loading branch information
nbelzer committed Mar 26, 2020
1 parent fb6f997 commit 2372a3d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Vimari Extension/js/lib/mousetrap.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Custom behaviour for Vimari implemented at line 185. Be aware of this
// when upgrading mousetrap.

/*global define:false */
/**
* Copyright 2012-2017 Craig Campbell
Expand Down Expand Up @@ -175,7 +178,11 @@
*/
function _addEvent(object, type, callback) {
if (object.addEventListener) {
object.addEventListener(type, callback, false);
// CUSTOMISATION:
// We set the useCapture to true such that events
// are handled before being dispatched to any EventTarget beneath
// it in the DOM tree.
object.addEventListener(type, callback, true);
return;
}

Expand Down

0 comments on commit 2372a3d

Please sign in to comment.