-
-
Notifications
You must be signed in to change notification settings - Fork 150
Customizing Key Handling on PdfViewer
Takashi Kawasaki edited this page Apr 29, 2025
·
1 revision
Because PdfViewer handles certain keys to allow users to scroll/zoom PDF view by keyboards, it may sometimes interfere with other widget's key handling, such as TextField's text input.
To customize the key handling behavior, you can use PdfViewerParams.onKey and PdfViewerParams.keyHandlerParams.
By default, PdfViewer handles the following keys:
| Key | Description |
|---|---|
| pageUp | Scroll up |
| pageDown | Scroll up |
| home | Go to first page |
| end | go to last page |
| equal | Combination with ⌘/Ctrl to zoom up (currently not I18N-ed) |
| minus | Combination with ⌘/Ctrl to zoom down |
| arrowUp | Scroll upward |
| arrowDown | Scroll downward |
| arrowLeft | Scroll to left |
| arrowRight | Scroll to right |
And, the other keys are not handled and handled by other widgets.
The following fragment illustrates how to use PdfViewerParams.onKey:
onKey: (params, key, isRealKeyPress) {
if (key == LogicalKeyboardKey.space) {
// handling the key inside the function
handleSpace();
return true;
}
if (key == LogicalKeyboardKey.arrowLeft || key == LogicalKeyboardKey.arrowRight) {
// returning false to disable the default logic
return false;
}
// returning null to let the default logic to handle the keys
return null;
},This document is for pdfrx 1.X.X versions. For the latest version, see doc/README.md