How to handle back key manually?

How can I handle back key manually? I’ve managed to get clicks like this:

document.addEventListener("backbutton", function () {
    console.log("BACK");
}, true);

But I can’t cancel it and because of that page pops. Any ideas? Thanks.

Platform.registerBackButtonAction()?