For the PDF Viewer, some of the key handling code is in chrome/browser/resources/pdf/pdf.js, where handleKeyEvent_() has a chance to intercept DOM keydown events. The rest is in PDFiumEngine (in C++) where it has OnKeyDown(), OnChar(), and OnKeyUp() methods.
We should figure out when to handle an event in JS vs when to handle it in C++. We do not want to end up in a situation where some developers handle keyboard events in JS, and others handle similar events in C++.
Furthermore, sometimes the JS key handling code ends up calling KeyboardEvent.preventDefault(). From the C++ side, PDFiumEngine::OnKeyDown() gets skipped, but OnChar() and OnKeyUp() still get called. Should OnChar() and OnKeyUp() be prevented as well somehow? Or should the C++ code just expect and handle OnKeyUp() calls without a corresponding OnKeyDown() call?
Comment 1 by dsinclair@chromium.org
, Jul 10 2017