You may want to check out this thread. It is dealing with exactly what you are asking about, debouncing.