如何检测小写字母

时间:2016-12-04 09:14:36

标签: glfw

如何用 glfw 检测小写字母?我可以检测到大写字母。例如,

if ( key == 'A' && action == GLFW_PRESS )
        std::cout << (char)key <<std::endl;

但是,在以下代码中,没有打印出任何内容。

if ( key == 'a' && action == GLFW_PRESS )
        std::cout << (char)key <<std::endl;

这是函数的声明

void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);

1 个答案:

答案 0 :(得分:3)

检查是否按下了SHIFT键:

if ( key == GLFW_KEY_A && action == GLFW_PRESS ) {
    if (mode == GLFW_MOD_SHIFT) {
      //uppercase
    }
    else {
      //lowercase
    }
}

http://www.glfw.org/docs/latest/group__mods.html

相关问题