rtf - C# Detect Key Press, avoid non-typing keys -


is there way proceed method if key being pressed not result in typing. i.e. shift key, control key etc without having specify of them. ideally, detect combinations of keys, example control+v = paste.

code similar below working with;

    if( (e.keydata == keys.left)          || (e.keydata == keys.right)          || (e.keydata == keys.home)          || (e.keydata == keys.end)          || (e.keydata == keys.up)          || (e.keydata == keys.down)         || (e.keydata == keys.shiftkey)         || (e.keydata == keys.controlkey)         ) return; 

but don't want add every single combination of keypresses.

any ideas?

protected override bool processcmdkey( ref message msg, keys keydata ) {   if ( keydata == (keys.control | keys.v) )     return true;   else     return base.processcmdkey( ref msg, keydata ); } 

that takes care of copy+paste. can override onkeypress , use char.isdigit and/or char.isletter (or char.isletterordigit) if needed. idea, don't think regular expression warranted here others have suggested.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -