Can't control the player model outside of the player creation function

I am creating the player in a separate function:

function createPlayer(scene) {
BABYLON.SceneLoader.ImportMesh("", "/images/", "player.glb", scene, function (newMeshes, particleSystems, skeletons, animationGroups) {
    let player = newMeshes[0]

    //Scale the model down
    player.scaling.scaleInPlace(0.3)
    player.position.z = -30

    const stopManAnim = scene.getAnimationGroupByName("playerRun");
    stopManAnim.start(true, 1.0, stopManAnim.from, stopManAnim.to, false);

    document.addEventListener('keydown', function(e){
        if(e.keyCode == 37 || e.keyCode == 65)
        {
            player.position.x > -1 ? player.position.x -= 1.2 : ''
        }

        if(e.keyCode == 39 || e.keyCode == 68)
        {
            player.position.x < 1 ? player.position.x += 1.2 : ''
        }
    })

    return player
})

}

How do I manipulate it in a function:?

const createScene =  () => {
const scene = new BABYLON.Scene(engine);

/**** Камера и освещение *****/
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.075, 35, new BABYLON.Vector3(0, 0, 0));
camera.attachControl(canvas, true);
const light = new BABYLON.HemisphericLight("HemiLight", new BABYLON.Vector3(0, 100, 50), scene)
const light2 = new BABYLON.HemisphericLight("HemiLight2", new BABYLON.Vector3(0, 50, -50), scene)

Hi rah-emil,

Sorry, I’m not sure I understand the question. You don’t appear to be calling createPlayer(...) in the second code sample. What kind of manipulation are you trying to do?