Skip to content

Commit

Permalink
Customise Mousetrap library
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 Vimari 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 Jul 25, 2020
1 parent c57cc43 commit abb69bf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 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,10 @@
*/
function _addEvent(object, type, callback) {
if (object.addEventListener) {
object.addEventListener(type, callback, false);
// VIMARI 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 abb69bf

Please sign in to comment.