473,769 Members | 4,470 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onKeyPress in Opera 7.11


I have included a file below that tests onKeyPress in Opera 7.11. I am
getting peculiar behavior. When the file is first loaded, pressing the
keypad + causes the textarea to get physically larger on the screen, and
pressing the keypad - causes the textarea to get physically smaller. I
click on the scrollbar then this behaviour stops and subsequent
keystrokes are displayed appropriately. Is this some kind of bug in
Opera 7.11?

=============== =============== =============== ===============
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 strict//EN">
<html>
<head>
<title>Title</title>
<script type="text/javascript">

var transcriptConte nts = "";
var lineCnt = 0;

function tprint(_line) {
transcriptConte nts += lineCnt++ + " "+ _line + "\n";
transcript.valu e = transcriptConte nts;
};

function Initialize() {
transcript = document.getEle mentById("trans criptId");
tprint("Ready.. .");
};

function OnKeyPress() {
var code;
var codeStr;
var charStr;
code = event.keyCode ?
event.keyCode :
event.charCode ?
event.charCode :
event.which;
codeStr = code.toString() ;
charStr = Code2Str(code);
tprint(" code:" + codeStr + " char:" + charStr);
return false;
};

function Code2Str(code) {
switch(code) {
case 57357:return '<Home>';break ;
case 57358:return '<End>';break;
case 57359:return '<PageUp>';brea k;
case 57360:return '<PageDown>';br eak;
case 57361:return '<UpArrow>';bre ak;
case 57362:return '<DownArrow>';b reak;
case 57363:return '<LeftArrow>';b reak;
case 57364:return '<RightArrow>'; break;
case 57370:return '<Insert>';brea k;
case 57371:return '<Delete>';brea k;
case 57376:return '<Alt>';break;
case 57377:return '<Shift>';break ;
case 57378:return '<Ctrl>';break ;
case 8:return '<Backspace>';b reak;
case 9:return '<Tab>';break;
case 10:return '<Shift-Tab>';break;
case 13:return '<Enter>';break ;
default:return String.fromChar Code(code);
};
};

</script>
</head>
<body onLoad="Initial ize()" onKeyPress="OnK eyPress()">
<p>Transcript </p>
<textarea name='transcrip t'
id='transcriptI d'
size=50
wrap="soft"
readonly
rows=22 cols=30 >
</textarea>
</body>
</html>
--
Life is an offensive, directed against the repetitious mechanism of the
Universe.
--Alfred North Whitehead (1861-1947)
Jul 20 '05 #1
5 4198


Albert Wagner wrote:
I have included a file below that tests onKeyPress in Opera 7.11. I am
getting peculiar behavior. When the file is first loaded, pressing the
keypad + causes the textarea to get physically larger on the screen, and
pressing the keypad - causes the textarea to get physically smaller. I
click on the scrollbar then this behaviour stops and subsequent
keystrokes are displayed appropriately. Is this some kind of bug in
Opera 7.11?


If you look at the View->Zoom menu of Opera 7 then you will find that
+/- are indeed mapped to zoom in/out by 10%

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
On Sun, 28 Sep 2003 13:44:01 +0200
Martin Honnen <Ma***********@ t-online.de> wrote:


Albert Wagner wrote:
I have included a file below that tests onKeyPress in Opera 7.11. I
am getting peculiar behavior. When the file is first loaded,
pressing the keypad + causes the textarea to get physically larger
on the screen, and pressing the keypad - causes the textarea to get
physically smaller. I click on the scrollbar then this behaviour
stops and subsequent keystrokes are displayed appropriately. Is
this some kind of bug in Opera 7.11?


If you look at the View->Zoom menu of Opera 7 then you will find that
+/- are indeed mapped to zoom in/out by 10%

<snip>

I suspected as much, but I am trapping all keyboard input and not
passing it through. The code traps +/- from the main keyboard but +/-
from the keypad on the right get through, UNTIL the textarea scroll bar
is clicked; then they too are successfully trapped. So, I assume that
you are saying that: "yes, it's a bug in Opera 7.11."
--
Life is an offensive, directed against the repetitious mechanism of the
Universe.
--Alfred North Whitehead (1861-1947)
Jul 20 '05 #3
Albert Wagner <al******@tcac. net> writes:
I suspected as much, but I am trapping all keyboard input and not
passing it through. The code traps +/- from the main keyboard but +/-
from the keypad on the right get through, UNTIL the textarea scroll bar
is clicked; then they too are successfully trapped. So, I assume that
you are saying that: "yes, it's a bug in Opera 7.11."


Actually, clicking anywhere in the text area (giving it focus)
prevents the zooming from working.

Not a bug. It is expected behavior. In Opera, the numeric keyboard
keys "+" and "-" have a default behavior, and you do nothing to
suppress it.

If you call the W3C Events DOM method "event.preventD efault()", then
the problem goes away.

Another solution is to change the call to the function to
onKeyPress="ret urn OnKeyPress(even t)"
so you further return the false that OnKeyPress returns. This also
prevents the default behavior.

Btw, your code is based on using a global event variable, which is a
bad idea that comes from IE. You should pass the event as an argument
to the handler function. Then it works in Mozilla too.

Also notice that Opera has changed the keyCodes in O7.20, so that it
matches IE and Mozilla, so some of the codes might need to be changed.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
On 28 Sep 2003 17:42:51 +0200
Lasse Reichstein Nielsen <lr*@hotpop.com > wrote:

<snip>
Thank you, Lasse. When I post, I always hope that you reply. I always
get more than just an answer to a question; I also get the why and how
to improve it. Thanks again.

--
Life is an offensive, directed against the repetitious mechanism of the
Universe.
--Alfred North Whitehead (1861-1947)
Jul 20 '05 #5
On 28 Sep 2003 17:42:51 +0200
Lasse Reichstein Nielsen <lr*@hotpop.com > wrote:
<snip>
Also notice that Opera has changed the keyCodes in O7.20, so that it
matches IE and Mozilla, so some of the codes might need to be changed.


I was wondering about those. What keycodes am I looking at from 7.11?

--
Life is an offensive, directed against the repetitious mechanism of the
Universe.
--Alfred North Whitehead (1861-1947)
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
9779
by: Fred Brown | last post by:
Hi, I want to cancel a certain key in JavaScript. To do so, I catch the event in OnKeyPress and cancel the default: <head> .... function f(evt) { var evt = (evt) ? evt : ((window.event) ? window.event : "") ...
7
4102
by: Kev | last post by:
I need to make some specific alterations to some JavaScript in webpages in order to comply with government guidelines on accessibility. Apparently, whenever the OnClick event is used, it must be accompanied by an alternative OnKeyPress event. The guidelines are very vague and I am not sure what this means. I have used the following piece of JavaScript inside the cell of a table: onclick="window.open('http://www.etc') Do I need to...
2
11126
by: Hasan Ammar | last post by:
Is it possible to set up hotkeys using onkeypress? I know it can be done with the usual alphanumeric keys, but what about function keys? or using ctrl/alt combinations? Does anybody have a tutorial/guide?
3
4792
by: addi | last post by:
I'm looking to perform input validation on an HTML input text element; specifically, I'm looking to prevent anything other than numerical characters from being entered. I've got it working just fine for English characters by using an 'onkeypress' event handler, where basically all that is done is a regular expression check of the character represented by window.event.keyCode against a string containing "0123456789". The problem I'm...
11
31083
by: LilAndy23 | last post by:
How can I use the onKeyPress event handler in Firefox? onKeyPress doesn't seem to fire in Firefox.
2
4180
by: ~toki | last post by:
How can i take the control of the key events in Class2 ? This is the code snipped that i'd tried (after try some others): public class Main : System.Windows.Forms.Form { protected virtual void OnKeyPress(System.Object sender, System.Windows.Forms.KeyPressEventArgs e) { /* Do Nothing */ } } public class Class1 : Main
1
1896
by: Simon Wigzell | last post by:
I'm using a javascript function to interecept all key presses and check for valid character and also check the length of the current string and if it is greater than a sent value, set the focus to the next field. I use this for input for a phone number in the format NNN NNN NNNN it will only allow numbers and will go to the 2nd field when there are 3 characters in the first field and go to the 3rd field when there are 3 characters in the...
3
5175
by: Robert Inder | last post by:
I am struggling to catch kestrokes within an Internet Explorer 6 window. My window happens to be displaying three frames, though I suspect a similar problem would arise with a single document. The "<body.." tag in each frame includes an "onKeyPress" handler to catch and act on key presses. And if I focus the window by clicking on the content of one of the documents, keystrokes are sent to the handler on its "<body..." tag.
1
7495
by: vega80 | last post by:
Hi. I have a problem with assigning an onkeypress-function to dynamically created input-boxes.I want to put the content of an input-field into a tag-list when the user hits enter. This works fine the first time (when the input-field is created in a non-dynamical way). The next input-field is created dynamically by a function that is called when the user hits enter (the previously generated input-field will be hidden). Then I'm trying...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10225
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10001
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3969
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.