473,795 Members | 3,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I alter key.charCode value ?

How are you ? :)
This code works on Internet Explorer:

function(event) {
event.keyCode = 'a';
}

So, No matter what you typed in the textbox or textarea, you would get
'a'.

However, above the code does not work on Firefox or Safari.(even
though I use event.charCode instead of event.keyCode).

Please give me your advice !
Mar 22 '08 #1
6 2163
VK
On Mar 22, 10:52 pm, jh3an <jh3...@gmail.c omwrote:
This code works on Internet Explorer:

function(event) {
event.keyCode = 'a';

}
That is your allusion. One cannot refactor user-initiated events, that
would allow so-called "interface stealing" and possible security
break. IE is no different here, at least IE6/IE7. Moreover keyCode is
a key _code_, not a string value, so not
event.keyCode = 'a';
but
event.keyCode = 65;
then but it doesn't matter because it will not work for the reason I
just explained.

If you want to make a virtual keyboard, then catch onkeydown event for
the input element, cancel this event and update element value with
your own input:

<input type="text" name="txt"
onkeydown="this .value+='a';ret urn false;">
Mar 22 '08 #2
Is there another way to do it ?
If I want to type in the middle of string, the result always goes to
end of string always.
That's why I tried to find a way to change key.charCode value.

HELP!!
Mar 22 '08 #3
VK
On Mar 22, 11:20 pm, jh3an <jh3...@gmail.c omwrote:
Is there another way to do it ?
No - unless on browsers with defective security I am not aware of or
unless it will be considered one day just fine to refactor user-
initiated events (I deeply hope it will never happen).
If I want to type in the middle of string, the result always goes to
end of string always.
On virtual keyboards the regular way to do it is by creating ranges:
one from the beginning to the current cursor position and other from
the current cursor position to the end. Combining it with the previous
tip, you can get what you want. See for instance Paul Gorodyansky's
virtual Russian keyboard:
http://ourworld.compuserve.com/homep...r/screen_e.htm
That's why I tried to find a way to change key.charCode value.

HELP!!
Mar 22 '08 #4
VK wrote:
On Mar 22, 10:52 pm, jh3an <jh3...@gmail.c omwrote:
>This code works on Internet Explorer:

function(event ){
event.keyCode = 'a';

}

That is your allusion.
Probably you meant "illusion", because "allusion" does not make sense here.
One cannot refactor user-initiated events,
You have yet to understand what refactoring actually is.
[...] Moreover keyCode is a key _code_, not a string value, so not
event.keyCode = 'a';
but
event.keyCode = 65;
then but it doesn't matter because it will not work for the reason I
just explained.
The latter works as supposed in MSHTML for the `keypress' event. You could
have performed a test at least before giving more bad advice.
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Mar 23 '08 #5
VK
[...] Moreover keyCode is a key _code_, not a string value, so not
event.keyCode = 'a';
but
event.keyCode = 65;
then but it doesn't matter because it will not work for the reason I
just explained.

The latter works as supposed in MSHTML for the `keypress' event. You could
have performed a test at least before giving more bad advice.
It does? Well, why am I not surprised...

Now you see how I missed you: any high level specialist like myself
needs a helper to clean up after him such as better wording or lesser
important details: so the specialist would not waste his valuable time
on that.


:-)
Mar 23 '08 #6
VK wrote:
>>[...] Moreover keyCode is a key _code_, not a string value, so not
event.keyCode = 'a';
but
event.keyCode = 65;
then but it doesn't matter because it will not work for the reason I
just explained.
The latter works as supposed in MSHTML for the `keypress' event. You could
have performed a test at least before giving more bad advice.

It does? Well, why am I not surprised...

Now you see how I missed you: any high level specialist like myself
needs a helper to clean up after him such as better wording or lesser
important details: so the specialist would not waste his valuable time
on that.
The only problem here is that *you* are the beginner posing as an expert,
and that other people I would consider real experts repeatedly have to waste
their time to correct your bad advice.
:-)
A smiley does not make any nonsense that you keep on posting any better.
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Mar 23 '08 #7

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

Similar topics

3
13572
by: M Simpson | last post by:
/* for the google index */ ALTER TABLE DEFAULT COLUMN DEFAULT VALUE I've worked out several stored procedures for altering the default column values in a table. They were compiled from books and code snippets found here. It was a pain to work out so I've decided to share my work and research here. This post is just my way of saying thanks to several others here for posting with their wisdom and intelligence.
4
21257
by: Thomas Christensen | last post by:
I'm trying to figure out what key the user pressed using a Danish keyboard layout. charCodeAt returns the correct number, but event.keyCode returns a wrong number, when using one of the keys that are different on a Danish keyboard layout. "-" returns 45 and 189 respectively. Etc. (The input-field in the sample code below displays the right character). I've tried setting the lang-parameter to 'da', but it doesn't make a difference.
3
4141
by: Kimi | last post by:
Hi, I'm trying to change a column on a DB2 table so that it has a default value but I cannot get it to work. Does anyone have any experience in this area. I'm trying with this statement: Alter Table x Alter column y default 0;
1
3265
by: brian.newman | last post by:
I'm running the following function in Firefox. I've thrown the alerts in to help figure out where the error is. The code terminates at the line var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode); I get no error in the javascript console, the code just stops cold (I don't get the second alert message). Do you have any idea why? function parseDateField(evt) {
7
6994
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get into the GUI because it is hard to describe in text. First of all what is the purpose of ALTOBJ()? This procedure was created mostly for ISVs who need to do produce change scripts to upgrade application from release to release, but it can also
2
3352
by: Alan Mailer | last post by:
I'm sorry if this one has been asked and answered a million times: Is it possible to have a VB6 app alter the name of an *existing* field in Access 2002 database? To be clear, I'm not talking about adding a new field to the Access database. I want to change the name of an *existing* field using a VB6 app. What type of VB6 code would you use to do this? And please, if your suggestion involves using Project References other than...
0
2791
by: spatik | last post by:
Hi, I have a tableevent] with a columnevent_description] as ntext and default value ''. Now, I want to change the column type to nvarchar(max) using this script, alter table alter column nvarchar(max) null ; The event_description column was created with a default value ''. Now this constraint is not allowing me to alter the column type. It throws an exception, Msg 5074, Level 16, State 1, Line 1
3
1757
by: noddy | last post by:
I have a button <input type="button" value="Get data"> When it is clicked a database is accessed and the data is eventually displayed on the screen. While the data is being retrieved the button is displayed in its "pressed in" state. When the data arrives and is displayed the button pops out to its normal "unpressed" state.
2
23413
by: vijaialphonse | last post by:
i have a table which has 3 columns, one of three is set to default value 0. Now i have to change data type of that particular column and its default value using sql query. am working with sql server 2005. am not getting any prob when i exec ALTER TABLE TABLE_NAME ADD COLUMN DATATYPE SIZE CONSTRAINT VALUE. but getting probs when exec ALTER TABLE TABLE_NAME ALTER COLUMN_NAME DATATYPE SIZE VALUE. Help me, thanx in advance
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10448
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...
1
10167
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
9046
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...
1
7544
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6784
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();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4114
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
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.