# Stuck keys on Kontakt's virtual keyboard



## Bo Clausen (Nov 12, 2017)

I'm getting stuck keys on Kontakt's virtual keyboard. Everything is working fine, it's just the annoyance of _seeing_ all the stuck keys on the virtual keyboard.

I've been googling around for answers to this problem, and I found that some of you use a "ghost note" blip at zero velocity to turn it off -

But I can not get my head around how to make this "ghost note" blip work - I hope somebody can point me into the right direction to solve this -

Here's my script:

It's monophonic - and it auto alternates between two groups (up/down) while note is held - and play a release sample when no keys is down -

```
on init
 SET_CONDITION(NO_SYS_SCRIPT_RLS_TRIG)
    
    declare polyphonic $new_id 
    declare $last_id
    
    message("")  
end on

on note
    note_off($last_id)
    
    $last_id := $EVENT_ID
    
    ignore_event($EVENT_ID)
    
    disallow_group($ALL_GROUPS)
    allow_group(0)
    
    $new_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
    
    wait(1000000)
    fade_out($new_id,100000,1)    
    
    while($NOTE_HELD = 1)
        disallow_group($ALL_GROUPS)
        allow_group(1)
        $new_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
        
        wait(1000000)
        fade_out($new_id,100000,1)
        disallow_group($ALL_GROUPS)
        allow_group(0)
        $new_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
        
        wait(1000000)
        fade_out($new_id,100000,1)
    end while   
end on

on release
    fade_out($new_id,100000,1)
    disallow_group($ALL_GROUPS)
 
    if (search(%KEY_DOWN,1) # -1)
        ignore_event($EVENT_ID)
    else
        allow_group(2)  
        $new_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)    
    end if
end on
```
Best regards
Bo


----------



## EvilDragon (Nov 12, 2017)

You should probably just use set_key_pressed_support(). Simple to implement, no need to fuss around with blip notes:


```
on init
    set_key_pressed_support(1)
end on

on note
    if (get_event_par($EVENT_ID, $EVENT_PAR_SOURCE) = -1)
        set_key_pressed($EVENT_NOTE, 1)
    end if
end on

on release
    if (get_event_par($EVENT_ID, $EVENT_PAR_SOURCE) = -1)
        set_key_pressed($EVENT_NOTE, 0)
    end if
end on
```


----------



## Bo Clausen (Nov 12, 2017)

Hej mr. Evil
You just made my day - it works just fine - and so simple (I wasn't aware of this "new" feature) -
Thanks a lot for your help - you're not Evil at all, you're a very kind man 
All the best
Bo


----------

