There are plenty of tutorials available here.
And the documentation for jQuery is very thorough.

How much experience do you have with writing JavaScript though?
If you don't know it I recommend learning vanilla JS before learning jQuery (or any other framework).

That is indeed a good code you have there. The problem is that I do not want to use a framework because I am not using it from before. I am not a fan of using the whole library for just one function. Also, I have never used jQuery before.

I like to make my own code (vanilla JS) because it is much better to maintain and understand exactly what I am doing!

So, what I have now is this:

<body onload="document.body.focus();" onkeyup="return keypressed(event)">
When the key is up it calls this function in JavaScript:
function keypressed(e) {
var intKey = (window.Event) ? e.which : e.keyCode;
if (intKey == 13) { // 13 = enter key
//something happens if the key is clicked
}
// here, you can add as many if sentences for key strokes as you want! (same as first)
return true;
}

At 7/25/12 10:20 AM, uglybetty wrote:
That is indeed a good code you have there. The problem is that I do not want to use a framework because I am not using it from before. I am not a fan of using the whole library for just one function.

That example code I gave is you is using far more than just one jQuery function.
But anyways, since you're still learning JavaScript it's a good idea for you to stay away from jQuery for now.

At 7/25/12 10:20 AM, uglybetty wrote:
I like to make my own code (vanilla JS) because it is much better to maintain and understand exactly what I am doing!

It's actually far more difficult to maintain, as jQuery, or other frameworks such as MooTools, are standards compliant and cross-browser compatible out of the box, your own vanilla code will not be. But that's fine for now; you're still learning JS so you don't need to worry about writing perfect code; just worry about learning.

At 7/25/12 10:20 AM, uglybetty wrote:
So, what I have now is this:

<body onload="document.body.focus();" onkeyup="return keypressed(event)">
When the key is up it calls this function in JavaScript:

You shouldn't use onload="" in the body element; it's slow, and is mixing your HTML and JavaScript (which makes your code obfuscated and creates redundant dependencies). Whenever possible avoid using any inline events with HTML, such as onload or onkeyup (or any others).

Note:
For the sake of brevity I'm not including code that will work in older browsers.
The code I'm posting will require a modern browser.

That will keep your logic entirely inside JavaScript and not in your HTML.

What this is doing is waiting for the Document Object Module, or DOM for short, to load. The DOM is basically a tree of your HTML; it allows you to treat the HTML you wrote as objects.
Anytime you want to do anything to your page, you need to wait for the DOM to load.

That is indeed a good code you have there. The problem is that I do not want to use a framework because I am not using it from before. I am not a fan of using the whole library for just one function.

That example code I gave is you is using far more than just one jQuery function.
But anyways, since you're still learning JavaScript it's a good idea for you to stay away from jQuery for now.

I know, but not like a function in JavaScript - in literal meaning of functioning a button press. Can I use void/sub in JavaScript instead of function?

I like to make my own code (vanilla JS) because it is much better to maintain and understand exactly what I am doing!

It's actually far more difficult to maintain, as jQuery, or other frameworks such as MooTools, are standards compliant and cross-browser compatible out of the box, your own vanilla code will not be. But that's fine for now; you're still learning JS so you don't need to worry about writing perfect code; just worry about learning.

My grandmother always makes the food ground up. I took it to my senses and always do it in JavaScript.

You shouldn't use onload="" in the body element; it's slow, and is mixing your HTML and JavaScript (which makes your code obfuscated and creates redundant dependencies). Whenever possible avoid using any inline events with HTML, such as onload or onkeyup (or any others).

Oh ok! On my site I have this onload. Whenever I open it by clicking enter (since I have a really fast site and a light one) my JavaScript runs. The problem is that the JavaScript is not loaded, it says "undefined". Should I have a delay?

Note:
For the sake of brevity I'm not including code that will work in older browsers.
The code I'm posting will require a modern browser.

That will keep your logic entirely inside JavaScript and not in your HTML.

That actually is really nice. I love it, but the problem is that older browser do not support it. Maybe on window load?

What this is doing is waiting for the Document Object Module, or DOM for short, to load. The DOM is basically a tree of your HTML; it allows you to treat the HTML you wrote as objects.
Anytime you want to do anything to your page, you need to wait for the DOM to load.

At 7/25/12 06:39 PM, uglybetty wrote:
Oh ok! On my site I have this onload. Whenever I open it by clicking enter (since I have a really fast site and a light one) my JavaScript runs. The problem is that the JavaScript is not loaded, it says "undefined". Should I have a delay?

What doesn't load?
What says "undefined"?

At 7/25/12 06:39 PM, uglybetty wrote:
That actually is really nice. I love it, but the problem is that older browser do not support it. Maybe on window load?

To support legacy browsers, such as IE6 or IE7, you would need to do something like this:

Note: This code is by no means an efficient solution; it's just an example.

That gigantic blog is why I kept it out of my original post, because it's not necessary.
If you need to support legacy browsers then you should use a framework to handle that for you, and if you're still learning JavaScript then you don't need to worry about supporting legacy browsers right now.

At 7/25/12 06:39 PM, uglybetty wrote:
That code looks more maintainable. The question is: will it work in Fire Fox?

Yes. All of the code I've posted works in Firefox.
Generally speaking you will only run into issues Internet Explorer.

If you use the jsfiddle version make sure the "result" window on the right has focus.
Pressing "ENTER" and "A" at the same time should trigger an alert.

Basically you need to record each key that is pressed, and each time a key is released, remove that key from the record.
That way your object/array/whatever will only contain keys that are currently pressed. To check if a combo is being pressed you simply need to check for the existence of each key, which is what this function does: