Ashwini Kumar describes basics of creating custom Openlayers behavior in his article. He doesn't focus on any specific functionality, but provides a skeleton.

Another example could be found in tutorial by cableman, who shows not only general structure (as above), but also example of functionality.