Hey there,
I am writing an application and would like to add some shortcuts like “Ctrl+S” for saving, but it doesn’t work. If I just press the “s” key, I will get the value ‘115’ in ‘temp’, so without ctrl everything works fine:
bool MainStage::keyPressed(const KeyPress& k, Component* c)
{
auto temp = k.getTextCharacter();
if (temp == 's')
{
saveProject();
}
return true;
}
But if I press ctrl and then “s” (or another key) the ‘temp’ value is always ‘0’. I thought I have to do something like this:
bool MainStage::keyPressed(const KeyPress& k, Component* c)
{
auto temp = k.getTextCharacter();
if (ModifierKeys::getCurrentModifiers().isCtrlDown())
{
if (temp == 's')
{
saveProject();
}
}
return true;
}
but this is pointless as long as the temp value is 0. What am I doing wrong?