Git commit c59759b14618ab2a81fa430f8074c5c95e6b9b38 by Maks Orlovich. Committed on 13/02/2011 at 18:52. Pushed by orlovich into branch 'master'. Fix keyCode for ( and similar in keydown/up We want to return something like ( for those to avoid confusion on arrow keys, which affected e.g. youtube. BUG: 224315 M +25 -3 khtml/xml/dom2_eventsimpl.cpp http://commits.kde.org/kdelibs/c59759b14618ab2a81fa430f8074c5c95e6b9b38 diff --git a/khtml/xml/dom2_eventsimpl.cpp b/khtml/xml/dom2_eventsimpl.cpp index f4b4c61..f01a533 100644 --- a/khtml/xml/dom2_eventsimpl.cpp +++ b/khtml/xml/dom2_eventsimpl.cpp @@ -899,10 +899,32 @@ int KeyboardEventImpl::keyCode() const { //Keycode on key events always identifies the -key- and not the input, //so e.g. 'a' will get 'A' - if (m_virtKeyVal != DOM_VK_UNDEFINED) + if (m_virtKeyVal != DOM_VK_UNDEFINED) { return m_virtKeyVal; - else - return QChar((unsigned short)m_keyVal).toUpper().unicode(); + } else { + unsigned char code = QChar((unsigned short)m_keyVal).toUpper().unicode(); + // Some codes we get from Qt are things like ( which conflict with + // browser scancodes. Remap them to what's on their keycaps in a US + // layout. + if (virtKeyToQtKey()->hasLeft(code)) { + switch (code) { + case '!': return '1'; + case '@': return '2'; + case '#': return '3'; + case '$': return '4'; + case '%': return '5'; + case '^': return '6'; + case '&': return '7'; + case '*': return '8'; + case '(': return '9'; + case ')': return '0'; + default: + kWarning(6000) << "Don't know how resolve conflict of code:" << code + << " with a virtKey"; + } + } + return code; + } } int KeyboardEventImpl::charCode() const