def keyPressEvent(self, event: PySide6.QtGui.QKeyEvent) -> None:
        """
        Handle key press events (e.g. moving cursor around).
        """
        movement_keys = {
            Qt.Key.Key_Up: -16,
            Qt.Key.Key_Down: 16,
            Qt.Key.Key_Right: 1,
            Qt.Key.Key_Left: -1,
            Qt.Key.Key_PageUp: 0,
            Qt.Key.Key_PageDown: 0,
            Qt.Key.Key_Home: 0,
            Qt.Key.Key_End: 0,
        }
        if event.key() in movement_keys:
            if QApplication.keyboardModifiers() & Qt.KeyboardModifier.ShiftModifier:
                if self.selection_start is None:
                    self.begin_selection()
            else:
                self.clear_selection()

            # FIXME: When holding Ctrl, only scroll the viewport
            preserve_relative_offset = False
            if event.key() == Qt.Key.Key_PageUp:
                new_cursor = max(self.start_addr, self.cursor - (self.display_num_rows - 1) * 16)
                preserve_relative_offset = True
            elif event.key() == Qt.Key.Key_PageDown:
                new_cursor = min(self.end_addr - 1, self.cursor + (self.display_num_rows - 1) * 16)
                preserve_relative_offset = True
            elif event.key() == Qt.Key.Key_Home:
                new_cursor = max(self.start_addr, self.cursor & ~0xF)
            elif event.key() == Qt.Key.Key_End:
                new_cursor = min(self.end_addr - 1, (self.cursor & ~0xF) + 0xF)
            else:
                new_cursor = self.cursor + movement_keys[event.key()]
            if self.start_addr <= new_cursor < self.end_addr:
                self.move_viewport_to(new_cursor, preserve_relative_offset)
                self.set_cursor(new_cursor, update_viewport=False)
            event.accept()
            return
        elif QApplication.keyboardModifiers() & Qt.KeyboardModifier.ControlModifier:
            if event.key() == Qt.Key.Key_Space:
                self.set_cursor(self.cursor, ascii_column=not self.ascii_column_active)
                event.accept()
                return
        else:
            t = event.text()
            if len(t) == 1:
                if self.ascii_column_active:
                    if t.isascii() and t.isprintable():
                        self._set_byte_value(ord(t))
                        event.accept()
                        return
                else:
                    if t in "0123456789abcdefABCDEF":
                        self._set_nibble_value(int(t, 16))
                        event.accept()
                        return
        super().keyPressEvent(event)

        Handle key press events (e.g. moving cursor around).
        
angrmanagement/ui/views/hex_view.py