I want to add a feature to my game where if Shift is held down, the player will move at an increased velocity.
That should be fairly straight forward due to the way game-loop logic works. Each call to the update method you are moving your character if they are pressing a direction. If you take this example on moving a character with the keyboard, you can add a run mechanic with shift by modifying the update() logic to this:
function update ()
{
player.setVelocity(0);
let velX = 0;
let velY = 0;
if (cursors.left.isDown)
{
velX = -300;
}
else if (cursors.right.isDown)
{
velX = 300;
}
if (cursors.up.isDown)
{
velY = -300;
}
else if (cursors.down.isDown)
{
velY = 300;
}
if (cursors.shift.isDown) {
velX *= 2.5;
velY *= 2.5;
}
player.setVelocity(velX, velY);
}
You can see I am just checking for the Shift key being held down, and if it is, I increase the velocity the box is moving at