OSX:检测SPACEBAR down和up事件 [英] OSX: detect SPACEBAR down and up events

查看:145
本文介绍了OSX:检测SPACEBAR down和up事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要录制我自己演讲的几千个简短的声音(我正在训练一个语音识别引擎的声学模型)



所以对于每一个,文本行显示在屏幕上,我必须说出来,并将音频捕获到.WAV中。

我找到了一个用于录制音频的示例项目;现在我试图找出如何进行键盘输入。



我想将SPACEBAR推下来开始录制并释放它以终止录音。 >

任何人都可以让我开始吗? (一个例子将是理想的!)



对不起,这可能真的很基础 - 我以前没有在OS X中做任何编码(虽然我已经做了许多iOS工作,所以我对Xcode和一些框架不陌生)

解决方案

如果您创建一个基本的Cocoa应用程序,您可以使用 NSResponder 的以下方法,其中 NSView 是一个子类,用于捕获所需的键上/下事件:

   - (void)keyDown :( NSEvent *)event; 
- (void)keyUp:(NSEvent *)事件;

使用 [event keyCode] 按键。


I need to record several thousand short soundbites of my own speech (I'm training an acoustic model for a speech recognition engine)

So for each one, a line of text presents itself on the screen and I have to speak it, and capture the audio into a .WAV

I found a sample project for recording the audio; now I am trying to figure out how to do keyboard input.

I would like to push the SPACEBAR down to start recording and release it to terminate the recording.

Can anyone get me started? ( an example would be ideal! )

Sorry, this is probably really really basic -- I haven't done any coding in OS X before (though I have done a lot of iOS work so I am no stranger to Xcode and some of the frameworks)

解决方案

If you create a basic Cocoa application, you can use the following methods of NSResponder, of which NSView is a subclass, to capture your desired key up/down events:

-(void)keyDown:(NSEvent*)event;
-(void)keyUp:(NSEvent*)event;

Use [event keyCode] to get the key pressed.

这篇关于OSX:检测SPACEBAR down和up事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆