Keyboard write Issue

What you want is State Change Detection. See: File -> Examples -> 02.Digital -> StateChangeDetection