Annoying Bump Sound with Keyboard Events in NSOpenGLView Subclass

I redefined NSOpenGLView to handle keyboard events. Event detection works fine, but every time I press a key, I hear and annoy the sound of terrain. How can I say my eyes are cooling?

Here my keyUp: method looks like this:

-(void) keyUp:(NSEvent *)theEvent
{
    NSString *characters = [theEvent charactersIgnoringModifiers];

    if ( [characters length] != 1 )
        return;

    unichar keyChar = [characters characterAtIndex:0];

    if ( keyChar == NSLeftArrowFunctionKey ) 
    {
        //do something
        return;
    }

    if ( keyChar == NSRightArrowFunctionKey ) 
    {
        //do something
        return;
    }

    if ( keyChar == NSUpArrowFunctionKey ) 
    {
        //do something
        return;
    }

    if ( keyChar == NSDownArrowFunctionKey ) 
    {
        //do something
        return;
    }
}
+3
source share
1 answer

, , , "". , " , ". () , , .

+3

Source: https://habr.com/ru/post/1771234/


All Articles