_registerEventHandlers() {
		// Make hexview and textview focusable by setting tabindex
		this.hexview.tabIndex = 0;
		this.textview.tabIndex = 0;

		// Handle focus on hexview
		this.hexview.addEventListener("focus", () => {
			this.activeView = 'hex';
			this.updateSelection();
		});

		// Handle focus on textview
		this.textview.addEventListener("focus", () => {
			this.activeView = 'text';
			this.updateSelection();
		});

		// Handle click on hexview
		this.hexview.addEventListener("click", e => {
			if (e.target.dataset.byteIndex === undefined) return;
			const index = parseInt(e.target.dataset.byteIndex);
			this.currentEdit = "";
			this.editHex = true;
			this.setSelectedIndex(index);
			this.hexview.focus(); // Ensure hexview gains focus
		});

		// Handle click on textview
		this.textview.addEventListener("click", e => {
			if (e.target.dataset.byteIndex === undefined) return;
			const index = parseInt(e.target.dataset.byteIndex);
			this.currentEdit = "";
			this.editHex = false;
			this.setSelectedIndex(index);
			this.textview.focus(); // Ensure textview gains focus
		});

		// Handle keydown events
		this.hexedit.addEventListener("keydown", e => {
			// If the target is an input (search UI), do not handle hex editor key events
			if (e.target.tagName.toLowerCase() === 'input') return;

			if (e.key === "Control") this.ctrlPressed = true;
			if (this.selectedIndex === null || this.ctrlPressed) return;
			if (e.key === "Escape") {
				this.currentEdit = "";
				this.setSelectedIndex(null);
				return;
			}
			if (this.readonly) {
				const offsetChange = _keyShouldApply(e) ?? 0;
				this.setSelectedIndex(this.selectedIndex + offsetChange);
				return;
			}
			// Handle key inputs
			const key = e.key;
			if (this.editHex && key.length === 1 && key.match(/[0-9a-fA-F]/)) {
				this.currentEdit += key;
				e.preventDefault();
				if (this.currentEdit.length === 2) {
					const value = parseInt(this.currentEdit, 16);
					this.setValueAt(this.selectedIndex, value);
					this.currentEdit = "";
					this.setSelectedIndex(this.selectedIndex + 1);
				}
			} else if (!this.editHex && key.length === 1) {
				const value = key.charCodeAt(0);
				this.setValueAt(this.selectedIndex, value);
				this.setSelectedIndex(this.selectedIndex + 1);
				e.preventDefault();
			} else {
				const offsetChange = _keyShouldApply(e);
				if (offsetChange) {
					this.setSelectedIndex(this.selectedIndex + offsetChange);
					e.preventDefault();
				}
			}
		});

		// Handle keyup events
		this.hexedit.addEventListener("keyup", e => {
			if (e.key === "Control") this.ctrlPressed = false;
		});

		// Handle scrolling for virtual scrolling
		this.hexeditContent.addEventListener('scroll', this.handleScroll.bind(this));
	}
Registers event handlers for the hex editor.