# vtk python doesn't support get key PgUp/PgDn

**URL:** https://discourse.vtk.org/t/vtk-python-doesnt-support-get-key-pgup-pgdn/16284
**Category:** Development
**Tags:** python, code
**Created:** [February 11, 2026, 3:04pm UTC](https://discourse.vtk.org/t/vtk-python-doesnt-support-get-key-pgup-pgdn/16284 "2026-02-11T15:04:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nam\_Le\_Hoang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nam_le_hoang/32/10358_2.png) [@Nam\_Le\_Hoang](https://discourse.vtk.org/u/Nam_Le_Hoang)
#### Post date: [February 11, 2026, 3:04pm UTC](https://discourse.vtk.org/t/vtk-python-doesnt-support-get-key-pgup-pgdn/16284/1 "2026-02-11T15:04:07Z")

</div>

Hi, I’m using `vtk==9.5.0` with python in PySide2. Below is my simple script that I try to catch user key press and do works. But when I type `PgUp` `PgDn` the `GetKeySym` return None . Just wanna know if vtk doesn’t support it at all or just in python?

```auto
import sys
from PySide2.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget
from vtkmodules.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
import vtkmodules.all as vtk

class VTKViewer(QMainWindow):
    """
    A PySide2 QMainWindow that embeds a VTK 3D viewer to display a point cloud.
    """
    def __init__ (self, parent=None):
        super(). __init__ (parent)
        self.setGeometry(100, 100, 900, 700) # x, y, width, height

        # Central widget and layout
        central_widget = QWidget()
        self.setCentralWidget(central_widget)
        layout = QVBoxLayout(central_widget)

        # Create the QVTKRenderWindowInteractor widget
        # This widget provides the VTK rendering context within a Qt application
        self.vtkWidget = QVTKRenderWindowInteractor(central_widget)
        layout.addWidget(self.vtkWidget)

        # Get the VTK renderer and render window from the interactor
        self.renderer = vtk.vtkRenderer()
        self.render_window = self.vtkWidget.GetRenderWindow()
        self.render_window.AddRenderer(self.renderer)
        self.renderer.SetBackground(0.1, 0.1, 0.9) # Set background color

        self.interactor = self.render_window.GetInteractor()
        self.interactor_style = vtk.vtkInteractorStyleMultiTouchCamera()
        self.interactor.SetInteractorStyle(self.interactor_style)
        self.interactor.AddObserver(
            vtk.vtkCommand.KeyPressEvent, self._when_key_pressed
        )

        self.interactor.Initialize()

        camera = self.renderer.GetActiveCamera()
        camera.SetPosition(2.5, 2.5, 2.5) # Example view from top-right-front
        camera.SetFocalPoint(0, 0, 0.2) # Focus on the base
        camera.SetViewUp(0, 0, 1) # Z-axis up
        self.render_window.Render()

    def _when_key_pressed(self, obj, event):
        key = self.interactor.GetKeySym()
        _ctrl_key = self.interactor.GetControlKey()
        _shift_key = self.interactor.GetShiftKey()
        _alt_key = self.interactor.GetAltKey()
        print(f"Key pressed: {key} (ctrl: {_ctrl_key}, shift: {_shift_key}, alt: {_alt_key})")

if __name__ == " __main__":
    app = QApplication([])
    viewer = VTKViewer()
    viewer.show()

    sys.exit(app.exec_())

```

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [February 11, 2026, 4:52pm UTC](https://discourse.vtk.org/t/vtk-python-doesnt-support-get-key-pgup-pgdn/16284/2 "2026-02-11T16:52:07Z")

</div>

I looked through the git history of `QVTKRenderWindowInteractor.py` to see what’s going on here.

It seems that when the keysym mappings were added to `QVTKRenderWindowInteractor.py`, these keys were skipped because there was uncertainty about how they were named.

I checked, and their names in Qt are `PageUp` and `PageDown` but their keysyms are actually `Prior` and `Next`.

So in `QVTKRenderWindowInteractor.py` at around line 720, you can change this:

```python
    # Key.Key_Prior : 'Prior',
    # Key.Key_Next : 'Next',

```

to this:

```python
    Key.Key_PageUp : 'Prior',
    Key.Key_PageDown: 'Next',

```

And then you can observe ‘Prior’ and ‘Next’ to see when those keys are pressed.

---

<div class="post-metadata">

### Author: ![Nam\_Le\_Hoang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nam_le_hoang/32/10358_2.png) [@Nam\_Le\_Hoang](https://discourse.vtk.org/u/Nam_Le_Hoang)
#### Post date: [February 12, 2026, 6:38am UTC](https://discourse.vtk.org/t/vtk-python-doesnt-support-get-key-pgup-pgdn/16284/3 "2026-02-12T06:38:05Z")

</div>

Thanks you. I can manage to make it works
