sensekey — Returns the ASCII code of a key that has been pressed.
Returns the ASCII code of a key that has been pressed, or -1 if no key has been pressed.
kres - returns the ASCII value of a key which is pressed or released.
kkeydown - returns 1 if the key was pressed, 0 if it was released or if there is no key event.
kres can be used to read keyboard events from stdin and returns the ASCII value of any key that is pressed or released, or it returns -1 when there is no keyboard activity. The value of kkeydown is 1 when a key was pressed, or 0 otherwise. This behavior is emulated by default, so a key release is generated immediately after every key press. To have full functionality, FLTK can be used to capture keyboard events. FLpanel can be used to capture keyboard events and send them to the sensekey opcode, by adding an additional optional argument. See FLpanel for more information.
![]() |
Note |
---|---|
This opcode can also be written as sense. |
Here is an example of the sensekey opcode. It uses the file sensekey.csd.
Example 354. Example of the sensekey opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform ; Audio out Audio in -odac -iadc ;;;RT audio I/O ; For Non-realtime ouput leave only the line below: ; -o sensekey.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; Initialize the global variables. sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 ; Instrument #1. instr 1 k1 sensekey printk2 k1 endin </CsInstruments> <CsScore> ; Play Instrument #1 for thirty seconds. i 1 0 30 e </CsScore> </CsoundSynthesizer>
Here is what the output should look like when the "q" button is pressed...
q i1 357967744.00000