Skip to content
ScriptCodex13 edited this page Oct 26, 2025 · 3 revisions

Input

Now we have got a window, but how do we interact with it ? That is right. Inputs !

Keyboard and mouse inputs

Inputs are very easy in Zap:

if(window.GetInput(zap::Key::A, zap::State::PRESSED))
{
    std::cout << "A pressed !" << std::endl;
}

if(window.GetInput(zap::Key::A, zap::State::RELEASED))
{
    std::cout << "A released !" << std::endl;
}

You call GetInput() and specify the button on your keyboard and if you want to check if it is pressed or released.

You can also use isKeyPressed or isKeyReleased and specify the Key as a Parameter:

if(window.isKeyPressed(zap::Key::A))
{
    std::cout << "A pressed !" << std::endl;
}

if(window.isKeyReleased(zap::Key::A))
{
    std::cout << "A released !" << std::endl;
}

Mouse inputs

You can also get mouse inputs with the GetInput() function.

For getting the mouse position need to use

std::array<double, 2> position = window.GetMousePosition();

as you can see the function returns an array with the type double and two indexes.

The position is relative to the top left corner of the window's view.

Clone this wiki locally