Fix saneKeyboardEvents + copy event handler stack overflow

https://github.com/desmosinc/mathquill/pull/30#issuecomment-224982931
diff --git a/src/services/saneKeyboardEvents.util.js b/src/services/saneKeyboardEvents.util.js
index 850968f..e6bfb4f 100644
--- a/src/services/saneKeyboardEvents.util.js
+++ b/src/services/saneKeyboardEvents.util.js
@@ -111,9 +111,9 @@
     }
     function checkTextareaOnce(checker) {
       checkTextareaFor(function(e) {
-        checker(e);
         checkTextarea = noop;
         clearTimeout(timeoutId);
+        checker(e);
       });
     }
     target.bind('keydown keypress input keyup focusout paste', function(e) { checkTextarea(e); });
diff --git a/test/unit/saneKeyboardEvents.test.js b/test/unit/saneKeyboardEvents.test.js
index 9247803..44c75d7 100644
--- a/test/unit/saneKeyboardEvents.test.js
+++ b/test/unit/saneKeyboardEvents.test.js
@@ -410,4 +410,17 @@
       el.trigger('input');
     });
   });
+
+  suite('copy', function() {
+    test('only runs handler once even if handler synchronously selects', function() {
+      // ...which MathQuill does and resulted in a stack overflow: https://git.io/vosm0
+      var shim = saneKeyboardEvents(el, {
+        copy: function() {
+          shim.select();
+        }
+      });
+
+      el.trigger('copy');
+    });
+  });
 });