尝试这个
<script type="text/javascript">
(function() /* Prevent Esc deleting imput and if input is readonly, stop backspace acting as 'Back' */
{
var inps = document.getElementsByTagName( 'input' ), /* Place BELOW all <input>s */
field;
function ih( obj, evt, func )
{
obj.attachEvent ? obj.attachEvent( 'on' + evt, func ) : obj.addEventListener( evt, func, false );
}
function k( e )
{
var evt = ( e || window.event ),
elem = evt.srcElement || evt.target,
ro = elem.getAttribute('readonly');
if( evt.keyCode == 27 || ( ro && evt.keyCode == 8 ) )
evt.preventDefault ? evt.preventDefault() : evt.returnValue = false;
};
for( var i = 0; ( field = inps[ i ] ); i++ )
ih( field, 'keydown', k );
})()
</script>
它可能有效,也可能无效。很多事情 [热键] 是无法避免的。来源:http ://www.webdeveloper.com/forum/showthread.php?217535-esc-key-clears-html-input-text-values