HighDots Forums  

Using keyboard keys to activate buttons

HTML Writing HTML for the Web (comp.infosystems.www.authoring.html)


Discuss Using keyboard keys to activate buttons in the HTML forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MikeB
 
Posts: n/a

Default Using keyboard keys to activate buttons - 05-06-2008 , 02:30 PM






Short question:
Can I create a form where the user can simply hit the "1" key on the
keyboard and a button click for a specific button on the form is
simulated?

Long explanation:
Hi, I'm learning HTML and CSS and JavaScript and all this interesting
stuff.

As an exercise we had a form that had two input fields and one could
press a button and the contents of the two fields would be added
together.

I thought it would be interesting to write an entire calcualtor
(similar to the one that comes with Windows) as an HTML page.

I got most of it right, I have buttons and an input field and buttons
to do the calculations.

What I was hoping to do as the cherry on top was to enable it for
keyboard access, so a user could press the keys (1, 2, 3 etc.) to
enter the values and then the calcualtion key (+, -, *, etc) without
having to click on each button.

I found that I could specify access keys in the HTML, but that works
weird.

In Firefox, it doesn't seem to work at all.

In IE, if I press Alt+1, it will cycle through (and enter) either 1,
2, or 3 (the three buttons I've defined accesskey values for).

Thanks for reading

Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Using keyboard keys to activate buttons - 05-07-2008 , 01:49 AM






Scripsit MikeB:

Quote:
Short question:
Can I create a form where the user can simply hit the "1" key on the
keyboard and a button click for a specific button on the form is
simulated?
That's not a short question, really. And questions don't get any
shorter, or any simpler, just by calling them "short".

Quote:
As an exercise we had a form that had two input fields and one could
press a button and the contents of the two fields would be added
together.
Did you do it? URL? The odds are that it is far more important to
analyze the basic solution than to invent new complexities. So how did
the page look like when scripting was disabled? Let me guess... a form,
with a button, and clicking on the button does nothing? No explanation
anywhere?

Quote:
I thought it would be interesting to write an entire calcualtor
(similar to the one that comes with Windows) as an HTML page.
It would be an exercise in futility, since the calculator would be
inferior even to the _simple_ (as opposite to "scientific") mode of the
Windows Calculator.

Quote:
I got most of it right, I have buttons and an input field and buttons
to do the calculations.
But you didn't learn yet that the way to share your HTML document is to
upload it on a web server and post the URL?

Quote:
What I was hoping to do as the cherry on top was to enable it for
keyboard access, so a user could press the keys (1, 2, 3 etc.) to
enter the values and then the calcualtion key (+, -, *, etc) without
having to click on each button.
You can do that, with the usual caveats, using JavaScript. That's
off-topic here. There's the HTML issue of associating scripts with
elements, with attributes like onkeypress, but that's really the trivial
side of the matter (and the details depend on the approach).

Quote:
I found that I could specify access keys in the HTML, but that works
weird.
Indeed. So forget them. To begin with, some browsers interpret
accesskeys as _activating_ a button, some just as _focusing_ on it.
Accesskey attributes in HTML are widely regarded as a failure, by people
who have tested the idea and analyzed the design. They are detrimental
to accessibility, since they may mask out built-in access key
assignments in browsers and other software.

Quote:
In Firefox, it doesn't seem to work at all.
You did something wrong. Wrong expectations?

Quote:
In IE, if I press Alt+1, it will cycle through (and enter) either 1,
2, or 3 (the three buttons I've defined accesskey values for).
You did something wrong. Maybe on line 42?

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #3  
Old   
MikeB
 
Posts: n/a

Default Re: Using keyboard keys to activate buttons - 05-08-2008 , 02:27 PM



On May 7, 1:49 am, "Jukka K. Korpela" <jkorp... (AT) cs (DOT) tut.fi> wrote:
Quote:
Scripsit MikeB:

Short question:
Can I create a form where the user can simply hit the "1" key on the
keyboard and a button click for a specific button on the form is
simulated?

That's not a short question, really. And questions don't get any
shorter, or any simpler, just by calling them "short".

I guess we'll just have to differ. I thought that was a short question
that was potentially answerable.

As I get to read about HTML, I realize there seems to be hardly any
issue that is either "short" or "simple", but still, one can hope.

Quote:
As an exercise we had a form that had two input fields and one could
press a button and the contents of the two fields would be added
together.

Did you do it? URL? The odds are that it is far more important to
analyze the basic solution than to invent new complexities. So how did
the page look like when scripting was disabled? Let me guess... a form,
with a button, and clicking on the button does nothing? No explanation
anywhere?
I did it. But we don't upload our pages to a server, we simply write
them in NotePad and then open them in IE or FireFox on our own
computers.

The instructor showed us how to register a domain name, but we've not
yet begun to upload any real pages to that.

Quote:
I thought it would be interesting to write an entire calcualtor
(similar to the one that comes with Windows) as an HTML page.

It would be an exercise in futility, since the calculator would be
inferior even to the _simple_ (as opposite to "scientific") mode of the
Windows Calculator.
Of course it is, but I learned something by writing it. I don't think
as a beginner I can start out and only write things that are going to
be better than the existing stuff out there. I think that's
unrealistic.

Quote:
I got most of it right, I have buttons and an input field and buttons
to do the calculations.

But you didn't learn yet that the way to share your HTML document is to
upload it on a web server and post the URL?
Unfortunately no.

But I thought, what the heck, I might try it and see if you woulod
offer a useful suggestion.

So here it is: http://fmechess.org/demo/calculator.html

Quote:
What I was hoping to do as the cherry on top was to enable it for
keyboard access, so a user could press the keys (1, 2, 3 etc.) to
enter the values and then the calcualtion key (+, -, *, etc) without
having to click on each button.

You can do that, with the usual caveats, using JavaScript. That's
off-topic here. There's the HTML issue of associating scripts with
elements, with attributes like onkeypress, but that's really the trivial
side of the matter (and the details depend on the approach).

Yes, I did use JavaScript. That was what the lesson was all about.


Quote:
I found that I could specify access keys in the HTML, but that works
weird.

Indeed. So forget them. To begin with, some browsers interpret
accesskeys as _activating_ a button, some just as _focusing_ on it.
Accesskey attributes in HTML are widely regarded as a failure, by people
who have tested the idea and analyzed the design. They are detrimental
to accessibility, since they may mask out built-in access key
assignments in browsers and other software.
So "forgetting accesskeys" what else do I use?

Quote:
In Firefox, it doesn't seem to work at all.

You did something wrong. Wrong expectations?
Perhaps. I tested the same set of keystrokes as that got some results
in IE.


Quote:
In IE, if I press Alt+1, it will cycle through (and enter) either 1,
2, or 3 (the three buttons I've defined accesskey values for).

You did something wrong. Maybe on line 42?
Ha ha... you are too funny. I didn't know the Finnish people has such
an acute sense of humor...




Reply With Quote
  #4  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Using keyboard keys to activate buttons - 05-08-2008 , 11:37 PM



Scripsit MikeB:

Quote:
Short question:
Can I create a form where the user can simply hit the "1" key on the
keyboard and a button click for a specific button on the form is
simulated?

That's not a short question, really. And questions don't get any
shorter, or any simpler, just by calling them "short".

I guess we'll just have to differ.
On which of my statements? If you call a 30-word question short, then we
do differ, and you are wrong. If you think that a question gets shorter
or simpler by calling it "short", then we do differ, and you are very
wrong.

Quote:
As I get to read about HTML, I realize there seems to be hardly any
issue that is either "short" or "simple", but still, one can hope.
Most issues about HTML are both short and simple, but there's little
need to _discuss_ them.

Quote:
I did it. But we don't upload our pages to a server,
You really shouldn't ask for help in HTML authoring for the WWW in
public before you know how to upload a page on a server and understand
the importance of posting a URL.

Quote:
The instructor showed us how to register a domain name, but we've not
yet begun to upload any real pages to that.
A ten-year old kid can upload a real page on a free server with her left
hand. Registering a domain name has nothing to do with it.

Quote:
But I thought, what the heck, I might try it and see if you woulod
offer a useful suggestion.

So here it is: http://fmechess.org/demo/calculator.html
That's not what I asked for. I asked for the URL of the _basic_
exercise.

Quote:
So "forgetting accesskeys" what else do I use?
Use the Force. And do things in the right order. First, create a page
that works without scripting. Then test it. Test it again - you surely
skipped some essential test. Then, time permitting, you might consider
whether you wish to add some optional enhancement using client-side
scripting. - In reality, time seldom permits, and in any case, scripting
as such is OFF-TOPIC in this group.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #5  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: Using keyboard keys to activate buttons - 05-09-2008 , 05:56 AM



Jukka K. Korpela wrote:
Quote:
Scripsit MikeB:

Short question:
Can I create a form where the user can simply hit the "1" key on the
keyboard and a button click for a specific button on the form is
simulated?

That's not a short question, really. And questions don't get any
shorter, or any simpler, just by calling them "short".

As an exercise we had a form that had two input fields and one could
press a button and the contents of the two fields would be added
together.

Did you do it? URL? The odds are that it is far more important to
analyze the basic solution than to invent new complexities. So how did
the page look like when scripting was disabled? Let me guess... a form,
with a button, and clicking on the button does nothing? No explanation
anywhere?

I thought it would be interesting to write an entire calcualtor
(similar to the one that comes with Windows) as an HTML page.

It would be an exercise in futility, since the calculator would be
inferior even to the _simple_ (as opposite to "scientific") mode of the
Windows Calculator.
For heaven's sake, give it a rest. It's an *exercise*. I'm sure when you
were learning all this, you went directly from zero to major
world-shaking innovations, but most of us go through a lot of
wheel-reinvention and wheel-imitation first.


Reply With Quote
  #6  
Old   
MikeB
 
Posts: n/a

Default Re: Using keyboard keys to activate buttons - 05-09-2008 , 08:04 AM



On May 8, 11:37 pm, "Jukka K. Korpela" <jkorp... (AT) cs (DOT) tut.fi> wrote:
Quote:
Scripsit MikeB:

Short question:
Can I create a form where the user can simply hit the "1" key on the
keyboard and a button click for a specific button on the form is
simulated?

That's not a short question, really. And questions don't get any
shorter, or any simpler, just by calling them "short".

I guess we'll just have to differ.

On which of my statements? If you call a 30-word question short, then we
do differ, and you are wrong. If you think that a question gets shorter
or simpler by calling it "short", then we do differ, and you are very
wrong.
Please tell me, sir. How many words am I permitted in a short
question?

Are all questions over the above limit "long" questions or do you have
several scales of grading the length of questions?

Quote:
As I get to read about HTML, I realize there seems to be hardly any
issue that is either "short" or "simple", but still, one can hope.

Most issues about HTML are both short and simple, but there's little
need to _discuss_ them.

I did it. But we don't upload our pages to a server,

You really shouldn't ask for help in HTML authoring for the WWW in
public before you know how to upload a page on a server and understand
the importance of posting a URL.
Who made you the boss of what I should or shouldn't do? If you don't
want to advise, just let it be, I can deal with no-one answering a
question.


Quote:
The instructor showed us how to register a domain name, but we've not
yet begun to upload any real pages to that.

A ten-year old kid can upload a real page on a free server with her left
hand. Registering a domain name has nothing to do with it.
I'm an old geezer. We didn't grow up with the right skillz.

Quote:
But I thought, what the heck, I might try it and see if you woulod
offer a useful suggestion.

So here it is:http://fmechess.org/demo/calculator.html

That's not what I asked for. I asked for the URL of the _basic_
exercise.

So "forgetting accesskeys" what else do I use?

Use the Force. And do things in the right order. First, create a page
that works without scripting. Then test it. Test it again - you surely
skipped some essential test. Then, time permitting, you might consider
whether you wish to add some optional enhancement using client-side
scripting. - In reality, time seldom permits, and in any case, scripting
as such is OFF-TOPIC in this group.

Thanks for all you help. NOT.



Reply With Quote
  #7  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Using keyboard keys to activate buttons - 05-09-2008 , 02:19 PM



Scripsit Harlan Messinger:

Quote:
For heaven's sake, give it a rest.
"It"? You fullquoted like a moron, or a clueless newbie.

Quote:
It's an *exercise*.
So what? It doesn't make it any more sensible, or any more on-topic.
Learning stupid things when you should study the basics isn't a
justification for anything.

Quote:
I'm sure when
you were learning all this, you went directly from zero to major
world-shaking innovations, but most of us go through a lot of
wheel-reinvention and wheel-imitation first.
I didn't waste my time babbling like that, to be honest. Sorry for
cheating that way.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #8  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Using keyboard keys to activate buttons - 05-09-2008 , 02:22 PM



Scripsit MikeB:

Quote:
Who made you the boss of what I should or shouldn't do?
My knowing far better than you do. But since you so clearly ask to
remain clueless, ignorant, and a nuisance in newsgroups, you cannot be
helped. Thanks for visiting the Internet.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #9  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: Using keyboard keys to activate buttons - 05-09-2008 , 02:58 PM



Jukka K. Korpela wrote:
Quote:
Scripsit Harlan Messinger:

For heaven's sake, give it a rest.

"It"? You fullquoted like a moron, or a clueless newbie.

It's an *exercise*.

So what? It doesn't make it any more sensible, or any more on-topic.
Learning stupid things when you should study the basics isn't a
justification for anything.
I didn't say anything about its topicality. As for the issue that I'm
challenging you on, since when is programming a small-scale
keyboard-driven interactive application for learning purposes stupid?


Reply With Quote
  #10  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Using keyboard keys to activate buttons - 05-09-2008 , 03:06 PM



Scripsit Harlan Messinger:

Quote:
I didn't say anything about its topicality.
I did. Which part of "comp.infosystems.www.authoring.html" do you fail
to understand? Followups set.

Quote:
As for the issue that I'm
challenging you on, since when is programming a small-scale
keyboard-driven interactive application for learning purposes stupid?
Ever since it started meaning you try to do "advanced" things without
having and without wanting to have a clue of the basics. ObHTML: That
applies to doing silly things in HTML "for learning purposes" as well.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.