Sunday, December 04, 2016

Why Do I "Go to 'Church'"?

A question was recently asked on Facebook: Why do you "go to 'church'"?

Here's my answer:

The "church" is designed as an alternative to the community of the world, as a different "nation" than the nation of USA or the nation of Mexico or the nation of France, etc.

If you lived in England but wanted to be a USA citizen, and you went through all the necessary process to do so, and then refused to live in the USA, what kind of USA citizen would you be?

A lousy one.

I can be committed to God without necessarily being committed to the kingdom of God (from "outside"), but I can't be a good citizen of the kingdom of God without being committed to that kingdom's community.

God doesn't tell us to "go to church to worship me" (the reason most of us have been taught since childhood for attending); rather, he tells us, over and over to, "be involved with one another; teach one another; encourage one another; bear one another's burdens; share with one another; love one another".

When you're alone, you can worship God. But when you're alone, you can't be one-another-ing.

Right now, "going to church" offers very little personal value to me, and often "costs" me something (not sleeping in; feeling more discouraged after attending than before; being bored; etc), and it would be easy to "skip church". But if I skipped, I'd essentially be saying "I'm not even going to try".

I can't control how the assembly goes; but I can control whether I go to assembly. And God told us to "go to assembly", not to worship him, but to "one another" each other. Whether the one-anothering actually happens is beyond my control in many respects, but I *can* control whether or not I'm there, available for one-another-ing.

And that's why I "go to 'church'".


Originally posted at:
http://kentwest.blogspot.com/2016/12/why-do-i-go-to-church.html

Friday, November 18, 2016

The Curse on Canaan

The question was asked recently, "Why did Noah have to curse Canaan?"

For those of you not familiar with the story: Noah and his three sons and the four wives of those four men had recently spent a year and change aboard the ark, with a bunch of smelly, high-maintenance critters. After disembarking, Noah planted a vineyard, maybe within a year or two, and then it was probably another year or three before he was drinking the wine from that vineyard.

Whether he intentionally got drunk, or had no idea wine would ferment into alcohol in this new post-Flood world (other clues in the text indicate that something had changed in the environment), the result was that he got wasted. Here's the text from Genesis 9 (WEB):
20 Noah began to be a farmer, and planted a vineyard. 21 He drank of the wine and got drunk. He was uncovered within his tent. 22 Ham, the father of Canaan, saw the nakedness of his father, and told his two brothers outside. 23 Shem and Japheth took a garment, and laid it on both their shoulders, went in backwards, and covered the nakedness of their father. Their faces were backwards, and they didn’t see their father’s nakedness. 24 Noah awoke from his wine, and knew what his youngest son had done to him. 25 He said,

“Canaan is cursed.
    He will be a servant of servants to his brothers.”
I'm not sure it's accurate to say Noah "had to curse" Canaan.

Two versed prior to this, in verse 18, you might notice that Moses specifically points out that "Ham is the father of Canaan", without saying something similar about the sons of Shem and Japheth. Now again, in verse 22, Moses again points out that "Ham, the father of Canaan" did such-and-such.

Why all this emphasis on Canaan?

Recall that Moses compiled Genesis (from books and records of the earlier patriarchs - cf Gen 5:1; 10:1; 36:1; etc), and he likely did this during the forty years of wandering in the desert, just before he was expecting to lead his people to an invasion of the land of ... wait for it, wait for it ... Canaan!

His people needed to understand that they need not fear the people of Canaan; the prophecy is that Canaan will be the servants of his people.

All part of God's plan to lead his people into the Promised Land of Canaan.


Originally published at:
http://kentwest.blogspot.com/2016/11/the-curse-on-canaan.html

Friday, November 04, 2016

Letting the Bible Define Its Own Terms

Sometimes we run into a word or phrase in the Bible, and not knowing exactly what it means, we turn to an English dictionary.

Whereas there's nothing wrong with that, the Bible wasn't written originally in English. Maybe we should look at a Bible-language dictionary (Greek/Koine for the New Testament, Hebrew for the Old, mostly).

That's better, but that still introduces the possibility that the word means something different in broader context than in the Biblical context.

Take the word "church", for example. We see the word "church" often in our English translations. (Arguably it's a terrible choice for translating the underlying Greek word "eklessia", but we're pretty much stuck with it since that's the pattern given to us by the KJV translators (by order of the King, by the way, not because it was the best choice).) If we were to look up the word "church" in a modern English dictionary, we'd see it has reference to physical buildings, to the people who assemble in such a building, to the local organization to which those people belong (such as a "congregation"), to the area/nation/world-wide organization to which the local organization belongs (such as a "denomination"), to the universal organization to which the wider organization belongs (the "universal" church), etc. But the usage of the word in the New Testament never refers to a physical building.

This same sort of thing can happen even if we turn to a Bible-language dictionary.

Thus we can see that dictionary definitions of a word don't necessarily match the Biblical usage of that word.

The best method of determining the meaning of a word is to let the Bible's usage of the word determine its meaning.

Here's another, perhaps explosively-debatable, example: "psalm". What is a "psalm"?

If we turn to non-Biblical sources, especially amongst brethren in the Church of Christ, the usual definition is that it at one time, in the Old Testament times, referred to a song accompanied by stringed musical instruments, but by the New Testament times, it simply referred to a song, without necessarily being accompanied by musical instruments, and from there, it is often insisted to mean a song definitely not accompanied by musical instruments.

Well, if you want to use non-Biblical sources as your authority, that's a fine definition. But what if we want to use the Bible as our source of authority for what the word "psalm" means?

In that case, let's just start at the beginning, and see if we can figure it out.

Using the computer web site www.biblegateway.com, I searched for "psalm", using the King James Version. The first hit I found was:
2 Sam 23:1 Now these be the last words of David. David the son of Jesse said, and the man who was raised up on high, the anointed of the God of Jacob, and the sweet psalmist of Israel, said,
Well, that doesn't tell us much, other than David was a "sweet psalmist". So let's look at the next two hits:
1 Chron 16:7-9 Then on that day David delivered first this psalm to thank the Lord into the hand of Asaph and his brethren. 8 Give thanks unto the Lord, call upon his name, make known his deeds among the people. 9 Sing unto him, sing psalms unto him, talk ye of all his wondrous works.
Ah, so now we know a "psalm" is a song, that can be sung to God and that can be used to thank God.

So David, the sweet psalmist of Israel, was a song-writer, who wrote songs of thanks to God.

There are only four more hits in the Old Testament:
Psalm 81:1 Sing aloud unto God our strength: make a joyful noise unto the God of Jacob. 2 Take a psalm, and bring hither the timbrel, the pleasant harp with the psaltery.
Psalm 95:1 O come, let us sing unto the Lord: let us make a joyful noise to the rock of our salvation. 2 Let us come before his presence with thanksgiving, and make a joyful noise unto him with psalms.
Psalm 98:4 4 Make a joyful noise unto the Lord, all the earth: make a loud noise, and rejoice, and sing praise. 5 Sing unto the Lord with the harp; with the harp, and the voice of a psalm. 6 With trumpets and sound of cornet make a joyful noise before the Lord, the King.
Psalm 105:1 O give thanks unto the Lord; call upon his name: make known his deeds among the people. 2 Sing unto him, sing psalms unto him: talk ye of all his wondrous works.
Using all the instances of the word "psalm" as found in the scriptures known by Timothy since he was a child (2 Tim 3:15), the word "psalm", as defined by the Bible, is a song of praise and joy and thankfulness to God, usually accompanied by instruments of various sorts.

But while we're here, notice that there's a whole book of psalms here in the Old Testament, 150 of them. (There are also a few other psalms, sometimes duplicates of some of these 150 psalms, scattered throughout the Old Testament in various places.) If we look at the characteristics of these psalms, we can see that sometimes they are not addressed to God, but to one another, such as in Psalm 1, which is simply telling the listener how the Godly are blessed, and the ungodly are not. We see that some do not mention musical instruments, and some do; some of those that don't mention instruments in the psalm itself mention instruments in the headings to the psalm. Some of the psalms are not prayers of praise and thanksgiving to God, but rather appeals to God for help, such as Psalm 3. Some of them are simply heart-rending emotional overflows.

Generally speaking, the Old Testament has defined its own usage of "psalm" as "a prayer or expression of, or an encouragement to, joy, sadness, thankfulness, etc, with God as the focus in some core way, set to music, and accompanied (when ascertainable one way or the other) with various instruments of music".

That is the way the term "psalm" is used in the Old Testament.

What about in the New Testament?

There are only nine hits. Here they are:
Luke 20:42 And David himself saith in the book of Psalms, The Lord said unto my Lord, Sit thou on my right hand,
Luke 24:44 And he said unto them, These are the words which I spake unto you, while I was yet with you, that all things must be fulfilled, which were written in the law of Moses, and in the prophets, and in the psalms, concerning me.
Acts 1:20 For it is written in the book of Psalms, Let his habitation be desolate, and let no man dwell therein: and his bishoprick let another take.
Acts 13:33 God hath fulfilled the same unto us their children, in that he hath raised up Jesus again; as it is also written in the second psalm, Thou art my Son, this day have I begotten thee.
Acts 13:35 Wherefore he saith also in another psalm, Thou shalt not suffer thine Holy One to see corruption.
1 Cor 14:26 How is it then, brethren? when ye come together, every one of you hath a psalm, hath a doctrine, hath a tongue, hath a revelation, hath an interpretation. Let all things be done unto edifying.
Eph 5:19 Speaking to yourselves in psalms and hymns and spiritual songs, singing and making melody in your heart to the Lord;
Col 3:16 Let the word of Christ dwell in you richly in all wisdom; teaching and admonishing one another in psalms and hymns and spiritual songs, singing with grace in your hearts to the Lord.
Jam 5:13 Is any among you afflicted? let him pray. Is any merry? let him sing psalms.
In the first five references, "psalm" refers to the book of 150 psalms found in the Old Testament.

In the remaining four references, we're simply told to sing and teach from psalms, without being given any new definition of the term "psalm".

You'll recall that Timothy had been left in Ephesus (1 Tim 1:3). You'll also recall that he learned from childhood how the Scriptures used the term "psalm" (2 Tim 3:15). When he read Paul's instruction to teach from and to sing "psalms", do you supposed he understood the word as the Scriptures used the word, or as non-Bible sources understood the word?

When either Paul or James instructs us to sing psalms, do you see them saying "sing psalms, except for the ones you might find already in Scripture"? If they didn't make an exception, who are we to add to their words? Can we not sing Psalm 150 as a congregation this coming Sunday morning? And if we do so, won't we feel weird encouraging each other (as Paul insisted we do) to praise God with the psaltery and harp? But should our comfort-zone be our standard of measure, or should the written word of God be our standard of measure?

Please note that this is not an argument for using instruments in our assemblies; there are reasons why we may not want to do that. But using a non-Biblical definition of the word "psalm", which conflicts with the Biblical definition of the word "psalm", should not be one of those reasons.

Let's let the Bible define its own terms whenever possible, rather than turn to non-Biblical sources, to inform our Christian walk.

Originally published at http://kentwest.blogspot.com/2016/11/letting-bible-define-its-own-terms.html

Sunday, October 30, 2016

Looking for Worship in All the Wrong Places. (What is worship/service?)

Lucas Necessary had a series of blog posts on this topic, which he then collated into one longer article. That article is reproduced here by permission.

Lucas Necessary·Sunday, October 18, 2015

Friday, October 28, 2016

Questions about Possible Roles for Women

  1. Is it okay for a woman to use the copier to make copies of the bulletin for handing out on Sunday morning?
  2. Is it okay for a woman to be the collector of items for the bulletin (contact point for announcements/events, articles to be printed, who's preaching when, etc)?
  3. Is it okay for a woman to be the producer/editor/printer of the bulletin?
  4. Is it okay for a woman to run the sound system?
  5. Is it okay for a woman to run the A/V recording system?
  6. Is it okay for a woman to make the sermon recordings available on the church web site?
  7. Is it okay for a woman to run the church web site? to handle the mechanics of domain registration / web site building/maintenance / publishing of material on the web site / creation of original material for web publication?
  8. Is it okay for a woman to prepare the bread and cup for Sunday's Lord's Supper? to clean up / clean the utensils / pick up the empty cups afterwards?
  9. Is it okay for a woman to get up from her seat to cross the aisle to pass the plate if the assigned server overlooks it?
  10. It is okay for a woman to count the collection and deposit it in the bank and keep the financial records?
  11. Is it okay for a woman to do the weekly head-count, and maintain the attendance records?
  12. Is it okay for a woman to participate in the serving of a regular meal during a fellowship meal, perhaps by going table-to-table with tea/Kool-aid refills, or by dispensing yummy hot-buttered rolls?
  13. Is it okay for a woman to participate in the serving of the Lord's Supper, perhaps by going pew-to-pew with the fruit of the vine cups, or serving the bread?
Some of these things may violate our comfort zones, but we are not called to pamper our comfort zones; we're called to encourage and equip one another to do good works, and to use one's God-given strengths to the benefit of the body.

There is room to discuss if these sorts of things result in a woman usurping authority (if an elder asks a woman to do Task X, is she usurping authority if she complies? if she refuses?) or in teaching a man (is she teaching a man if she writes a web article? if she writes a song that gets included in our hymnals 50 years later?), but we shouldn't just knee-jerk react against, without prayerful consideration, a woman filling these roles.

Originally published at: http://kentwest.blogspot.com/2016/10/questions-about-possible-roles-for-women.html

Family or formality: Why do saints assemble? by Lucas Necessary

Family or formality: Why do saints assemble? 

by Lucas Necessary

Lucas Necessary published this article on Facebook, Friday, October 21, 2016. I have reproduced it here, as Facebook requires a login account, which means not everyone can browse to the original article.

I used to think that we assembled "for worship," but interestingly Paul says, "let all things be done for edification." (1 Cor 14:26) In fact, never does God describe our Christian assembly as being something done "to worship Him." But back when I thought that He did, I saw the assembling of the saints as formality, not family, and I have to be honest—that view was destructive and hampered my ability to serve Christ with my life.

Anyway, God never says “worship service,” or “Bible class,” but He does use some very interesting terminology that I think apply to the assembling of the saints: equipping, being mended, being fully trained, and being made complete.

Sorry, zero Bible results.

One reason that we assemble with our brothers and sisters in Christ is for, "the EQUIPPING of the saints for the work of service, to the building up of the body of Christ.” (Eph 4:12-15) The word "equipping" here is from a Greek word, "katartizo."

This basic word is also used when Jesus was walking in Matthew 4:21, He said, "Going on from there He saw two other brothers, James the son of Zebedee, and John his brother, in the boat with Zebedee their father, MENDING their nets; and He called them.” (This time katartizo is mending.)

That makes sense. Edification is "building up," and certainly assembling with my brothers and sisters does that for me! But it also mends the spiritual and emotional wounds that I get throughout the week, like net (as a fisher of men) that has been beaten and battered.

That's still not the end of the story, though. Assemblies always featured "instruction," and often we are "able to instruct one another” (Romans 15:14). In that sense, Luke 6:40 used "equipping," and "mending" a little differently, saying,

"A pupil is not above his teacher; but everyone, after he has been FULLY TRAINED, will be like his teacher." Being equipped as saints is the same thing that Jesus describes as BECOMING FULLY TRAINED." (This time katartizo is about training.)

And I think there’s a reason for the above paragraph, too. Although our assemblies these days don't feature much more than a bunch of people listening to one "smart lecturer," early Christians "each had a psalm, a teaching, a revelation." (1 Cor 14:26) I imagine that this really did help them become fully trained, and that training (in a non-hostile environment with spiritual family) probably helped them much more effectively spread the gospel.

I guess I'll end with one other thing that I noticed. Equipping, mending, and being fully trained lead to one other use of the very same word:

"Now I exhort you, brethren, by the name of our Lord Jesus Christ, that you all agree and that there be no divisions among you, but that you BE MADE COMPLETE in the same mind and in the same judgment." (1 Cor 1:10) (And this time katartizo is about being made complete.)

When we assemble and do all things for the building up, we are being made complete. And all these things, then, are a lot more enticing than a mere checklist of things that we have to do to "keep God happy." As we are all members of the body of Christ, we all have different functions. In your own body, an eye is important, and so is a leg, though they serve very different purposes. Christ's church is the same way! As we assemble together, we have more people with various talents, and we truly start to be made complete!

Saturday, October 15, 2016

Where Is Our Emphasis

When John the Baptist came preaching (Luke 3), he told the people to change their mindsets ("repent"), and to bring forth fruit consistent with that change of mindset.

Three groups of people then asked him what they should do. He did not tell them to pray more, or to read their Bibles, or to go to church more consistently, or to give more to the Temple, or to preach/teach others.

He gave each group an answer based on personal economics:

To the multitudes he said, "If you have extra, share it with those who have nothing."

To the tax-office employees he said, "Don't charge more than has been appraised; you've no right to that extra."

To the soldiers he said, "Don't use your muscle to get into the 'Protection' racket, and don't be making false charges against anyone."

John's preaching was a "social" gospel, not a "religious" gospel.

And what did Jesus preach?

His sermon in his home town (Luke 4:16ff) was not about the importance of baptism, or instruction in how to pray, or an exposition of the minor prophets. It, too, was a "social" gospel - about bringing good news to poor people, healing the heart-sick, proclaiming freedom to the imprisoned, healing disease like blindness, providing relief to those who are at the end of their rope, and to proclaim a new regime, the rulership of God.

The Pharisees were all about getting right the legal aspects of religion. John and Jesus were all about meeting the needs of needy people. Jesus was about the internals ("wash the inside of the cup"), not the externals, and about the weightier matters of the law - justice, mercy, and loyalty (without neglecting the legalities, however).

Where is our emphasis?

Are we told to assemble to worship God, or to prod one another into doing good works? Are we told to assemble to faithfully execute specific rituals, or for each of us to build one another up using whatever gifting God has provided to each one of us?

Where is our emphasis?

Saturday, October 08, 2016

Putting the Math to the Universe

According to the web site Space.com the universe is "approximately 13.8 billion years old" (we'll round it to 14 billion, which is 14 * (10^9) in scientific notation) and contains 1,000,000,000,000,000,000,000,000 stars, or a '1' with 24 zeros after it" (1 * (10^24) in scientific notation). It's of note that the article says this number is "likely a gross underestimation".

Let's calculate how many stars would have to form, on average, per year, to form 1 * 10^24 stars over the course of 14 * (10 ^ 9) years. Just plug the numbers into any Google search bar and Google will do the math for you:

(1 * (10 ^ 24))  /  (14 * (10^9))

The answer is that on average, 71,428,571,428,571.4 stars must've formed every year since the Big Bang. We can divide that by 365.25 days in a year to find out how many stars must be forming every day:

71,428,571,428,571.4 / 365.25

The answer is: 195,560,770,509.436

Huh. I don't see nearly 200 billion new stars appearing in every night sky. Maybe something's wrong with my math. Or my observing of the night sky. Or the idea that all these stars have formed naturalistically over the course of 14 billion years.

Well, math is math; it just works.

And whereas I might not see 2 billion stars appear in every night sky, surely I'd see a few new stars appear over the course of my life.

So maybe the evolutionary theory is wrong; maybe all, or at least most, of the stars were created in one brief burst of creative activity at the universe's beginning. The math and observations certainly work better with that idea.

Friday, July 01, 2016

Rules vs Relationship

  • Old Covenant - Get the legalities right, and the relationship with God will be right. (Based on "don't touch, don't taste, don't handle" rules.) 
  • New Covenant - Get the relationship with God right, and the legalities will be right. (Not based on "don't touch, don't taste, don't handle" rules.)
Both "systems" have rules, but one is rules-based, and the other is relationship-based. The relationship you have with your government is rules-based; the relationship you have with your spouse is relationship-based. Both have rules, but their foundations are fundamentally different.

The kingdom of God is not about replacing one legal system (having rules written in stone for all to see) with a different legal system (having rules hidden between the lines, perceived only if you have the correct study method and love for the Truth, found only by a few). It's about replacing a legal system, wherein you wash the outside of the cup, with a relationship system, wherein you wash the inside of the cup.

If you have to ask, "Is X a sin?", you're living by a rules-based system. If you instead ask, "Does God want me to do X", you're living by a relationship-based system. Both systems should result in you avoiding sinful activities, but one system causes you to worth-ship a legal book/system, and the other causes you to worth-ship a Person.

Tuesday, June 28, 2016

"the New Testament pattern for worship"

"the New Testament pattern for worship"....

The very first Christians worshiped in the Temple, daily. What do you suppose they did during the daily instrumental praise which was being led from about 30 feet from their meeting area? Why doesn't Luke record the controversy that would surely ensue had the Christians been plugging their ears and telling their friends and families they were now sinning if they sang along with the instruments? Why didn't the enemy Jews ever list this point as one of the charges against the Christians? At any rate, the authorized pattern here is for us to assemble in some place where non-Christians are worshiping God with instruments.

And what about their daily meetings? That's the original New Testament pattern of worship. But we've subtracted from that pattern.

Why don't we take turns in the assembly, one by one, using whatever gift God has given us in order to build up the body? This is the pattern taught by Paul to the Corinthians.

Why do we take up a collection every week, perpetually, to pay the preacher and electric bill, pressing everyone to give? The New Testament pattern is for the giving to be a year-long fund-raising effort, by the wealthier, to give to the less wealthy. The poor didn't give; they received. And the money was not used to pay church expenses.

The New Testament pattern for the Lord's Supper is to eat it at night, not in the morning, as part of a bigger meal that should also feed the poor.

We have done very well at adapting the pattern of the Catholics so it looks at first glance like it came from the NT, but we've done a very poor job of following the actual NT "pattern".

And when Paul instructs his readers to teach one another using psalms, isn't it adding to God's word to insist that means "psalms, except the ones God has already given you"? Isn't it subtracting to not use those psalms for teaching when Paul himself used them often in his teaching?

Truth be told, there is no "pattern for worship" in the NT. But we have a psychological need for such a pattern, so amazingly we find that pattern (and explain away the pattern elements mentioned above that don't fit the pattern we've "discovered").

In the old covenant, based on keeping the letter of the law, God gave a definite written-in-stone pattern for worship. The new covenant is not like the old; it's based on keeping the spirit, not the letter of the law. But we (like children) have that psychological need for law, and so we've read between the lines and jigsawed this puzzle-passage with that puzzle-passage and have "found" the "New Testament pattern for worship".

We've gone from instructions written for all to see to instructions that are hidden so well that only "we", for two hundred out of two thousand years, have been able to successfully find and keep them.

Paul said that if law could bring life, the Mosaic law would have been the law to do it (Gal 3:21). And it couldn't do the job. Why then do we seek to find a different legal system? Paul said that doesn't work.

The new legal system, the law of Christ, is not a letter-of-the-law system. Instead, the law of Christ is fulfilled by bearing one another's burdens (Gal 6:2); the perfect law of liberty is fulfilled by taking care of orphans and widows and living a clean life (Jam 1:25-27); the royal law is fulfilled by loving your neighbor (Jam 2:8). This is the New Testament pattern of worship - to live one's life day-by-day honoring God with your lifestyle (Rom 12:1). It is not following an imagined set of rules on a certain day, rules having more in common with medieval Catholic practices than first-century apostolic practices.

Saturday, June 25, 2016

A Simple Web-Based Morse Code Keyer Using HTML and Javascript

Introduction

For some years I've wanted to write a little app that allowed me to use a couple of keys on my computer keyboard (or the mouse buttons on my mouse) as a dit/dah keyer, but to make it available for other hams, I wanted it in a universal language

Whereas Windows users have VisualBASIC, Linux and Mac users do not, and whereas Linux/Mac users have shell scripting, such is pretty limited in the Windows world.

But everybody has a web browser.

It's only recently that the HTML5 web standard has made my goal fairly trivial.
So if you'd like to code a bit of web-page to play some computer-keyboard Morse, come along....

Of course, you'd probably like to know what the result will be, before you follow these instructions, so click here to give the keyer a tryout.

The HTML Skeleton Document

If you've never written a web page, let's start out with that. I won't deal with all the exacting web standards, but I will do some of the basics. Open a text editor of some sort that produces plain ASCII text (like Notepad on Windows, or TextEdit on Mac, or Gedit on Linux - be aware that the Mac TextEdit has a few gotchas; you have to remember to convert to Plain Text before you save your document, and to manually add the .html extension, and to turn off Smart Quotes and Smart Dashes in the Edit / Substitutions menu), and type in the following:

Hello, World!
Save the document as plain text, giving it a name like MorseKeyer.html. If you have a web presence, you can place this file on your web server, but if you don't, just save it to your hard drive, perhaps on your Desktop. Then open a web-browser, and either browse to your web server, or do a File / Open and browse to the document. When you open it, you should see the words "Hello, World!" in your web-browser. Yea! You have a web page. But it's really not up to web standards, so let's add the basic minimum it should have. Edit your document so that it now looks like the following:

<html>
<head>
</head> 
<body>
"Hello, World!"
</body>
</html>

The blank lines are not necessary, but they help to break the code up into visual blocks that make the code more readable.

This code doesn't exactly meet proper web standards, but it's good enough for our purposes. Save the document (as plain text, remember, with an .html extension), and then refresh (or reload) your web document/page. You shouldn't see any visible change.

Developing Our Page

Now, in the <head> and </head> lines, add this little bit:

<head>
        <title>My Morse Code Keyer</title>
</head>
Save the document and reload it in your web-browser, and you should see the Window or Tab title change to say "My Morse Code Keyer".

The <header> section is for web-page housekeeping stuff; the <body> section is where most of your web-page code goes.

In the <body> section, replace the "Hello, World!" with something more meaningful, like:

<body>
<h1>Welcome to Kent's Web-based Morse Code Keyer!</h1>
<p>Press the left arrow key for a dah, and the right arrow key for a dit.</p>
</body>
(Later, you can choose to use different keys than what's convenient on this MacBook keyboard on which I'm currently typing, and change the message accordingly.)

The <h1> tells your web-browser to display the enclosed text as a header, using the built-in definition for the first-level of headers. An <h2> would use the second-level of built-in header definitions, etc.

The <p> defines its enclosed text as being a paragraph. Although not strictly required for your web page to work, it's good to get into the habit of using this tag around your paragraphs.

Save your document, reload it in your web-browser, and you should see the appropriate changes.

Using Javascript to Watch for a Keypress

Now we need to do a bit of Javascript programming, as we need a little more programming power than HTML by itself can handle. Since Javascript is built into modern web browsers, we won't have to download/install anything extra. And despite the similarity in names, Javascript has no relation to Java; they are two separate programming tools.

Now we need to watch for a keypress. Later we'll generate the code to generate the dit and dah tones, based on which key is pressed.

In the <body> section, just above the closing </body> tag, add this section:
<script>
document.addEventListener("keydown", dealWithKeyboard, false);

function dealWithKeyboard(event) {
    alert("Hey! A key has been pressed");
}
</script>
This code tells the web-browser that this is a Javascript script (more properly the <script> line should be <script type="text/javascript">).

The script command, "addEventListener" tells the browser (or more accurately, your document in the browser) to listen for an event, in this case the event of a key being pressed down (you could also listen for a keyup, or a mouse button, or several other options), and when it hears one, to run another piece of code called a "function", which is named "dealWithKeyboard" (people with some experience programming with functions should notice there is no "()" pair at the end of the function name). In the next thee lines we build that function ourselves, which simply displays a message via the "built-in" function of "alert".

We could call the function pretty much anything we wanted, as long as it matches both in the addEventListener command and in the function definition. For example, we could call it "playMorseTones" if we wanted. The "false" operator at the end of the addEventListener command just tells the command to not "capture" further input.

Save your file and reload the page in your browser. Now when you press a key, you should see that message.

Which Key Was Pressed?

Of course, we need to know which key was pressed, so change the function to this:
function dealWithKeyboard(event) {
    alert(event.keyCode + " has been pressed");
}
The "event" parameter holds the keycode of the key that is pressed, and passes it to our function. The line "function dealWithKeyboard(event)" tells the system that "dealWithKeyboard" is a function, and it's being given all the information that is contained in the variable "event", which includes quite a bit of stuff, but of most interest to us, the keycode of the key that was pressed.

The ".keyCode" is a built-in function that returns the keycode's value from that "event" parameter. If you wanted to, you could use a different name for the "event" parameter, such as "e" or "theKeyThatWasPressed", but "theKeyThatWasPressed.keyCode" is more tedious to type than "e.keyCode", which itself is not quite as self-explanatory as "event.keyCode".

Save your .html file, and refresh your browser page, and press some keys to see what keycodes they generate.

Now would be a good time to try pressing a few keys to figure out what you want to use for your Dit and your Dah, and make a note of the keycodes generated by those keys. I'm going to use 39 for the right arrow (dit), and 37 for the left (dah), on my keyboard.

Checkpoint

At this point, your entire "MorseKeyer.html" document should look something like this:

<!DOCtype html>
<html>
<head>
        <title>My Morse Code Keyer</title>
</head>
<body>
<h1>Welcome to Kent's Web-based Morse Code Keyer!</h1>
<p>Press the left arrow key for a dah, and the right arrow key for a dit.</p>

<script>
document.addEventListener("keydown", dealWithKeyboard, false);

function dealWithKeyboard(event) {
    alert(event.keyCode + " has been pressed");
}
</script>

</body>
</html>

Responding to the Appropriate Keypress

Now that we've captured the keypresses, we have to do different things based on which key is pressed. We'll handle this with a "switch" statement, which is a form of an If-Then statement you may remember from your high school programming class.

We no longer need the pop-up box telling us what key we've pressed, so we can delete it, or just comment it out. Let's comment it out, so that it won't be treated like a computer programming instruction anymore, but just a comment. This way we can always uncomment it later if we need to test other keys.
Just add a couple of forward slashes somewhere at the front of the line, like so:

//     alert(event.keyCode + " has been pressed");
Now if you reload your page and press a key, you won't see anything happen, because our function no longer does anything.

So let's give it something to do.

Just after the newly-commented alert line, add these lines:
switch(event.keyCode) {
  case 39:
    alert("You pressed the Right Arrow");
    break;
  case 37:
    alert("You pressed the Left Arrow");
    break;
}
Now if you reload your web page, and press one of your two chosen keys, you should see a pop-up window telling you which key you pressed. All other keys are ignored.

I don't like "magic numbers" in my program, so rather than test the case of "40" and "39", I'm going to use variables with meaningful names here, so that the lines become

case _Dit:
and

case _Dah:
Then earlier in the script, just below the opening <script> tag, I'll define these two variables. The entire <script> section now looks like this:

<script>   
        var _Dah = 40; // 40 = down arrow
        var _Dit = 39; // 39 = right arrow

        document.addEventListener("keydown", dealWithKeyboard, true);

        function dealWithKeyboard(event) {
//          alert(event.keyCode + " has been pressed");
            switch(event.keyCode) {
                case _Dit:
                   alert("You pressed the Dit key");
                   break;
                case _Dah:
                   alert("You pressed the Dah key");
                   break;
             }
          }
</script>
Now if you want to change your keys for Dit and Dah, just change those variables.

Notice that all other keypresses are ignored. We could put a default case for those, like so:

switch(event.keyCode) {
    case _Dit:
        alert("You pressed the Dit key");
        break;
    case _Dah:
        alert("You pressed the Dah key");
    break;
    default:
        alert("You pressed an invalid key");
        break;
}

Replace Message With Tones

We're nearly there. All that is left is to generate the tones.

For the last and final section of our program, we'll just replace the pop-up alert boxes with sound-generation code.

So comment out the Dit alert lines, and add the following code:

//                    alert("You pressed the Dit key");

                    // Create the audio context
                    var context = new AudioContext();
                    var oscillator = context.createOscillator();
                    oscillator.frequency.value = 220;
 
                    // Connect the oscillator to our speakers
                    oscillator.connect(context.destination);

                    // Start the oscillator now
                    oscillator.start(context.currentTime);

                    // Stop the oscillator after "DitLength" seconds from now
                    oscillator.stop(context.currentTime + 1);
Now if you save the code and reload your web page, and then press the Dit key, you should hear a tone of 220 hertz. (The Dah key does not yet work.)

Again, there are a couple of "magic numbers"in this code, so let's replace them with variables.

Replace the "220" with "_Freq", and the "1" with "_DitLength", and then declare these two (and a Dah) variables:

        var _Dah = 37; // 37 = left arrow
        var _Dit = 39; // 39 = right arrow
        var _Freq = 220; // Tone frequency
        var _DitLength = 1; // Length of the Dit
        var _DahLength = _DitLength * 3; // A Dah is usually three times a Dit
and replace those magic numbers with their variable names.

Now add the Dah key handler: replace the alert-Dah line with:

//                    alert("You pressed the Dah key");

                    // Create the audio context
                    var context = new AudioContext();
                    var oscillator = context.createOscillator();
                    oscillator.frequency.value = _Freq;
 
                    // Connect the oscillator to our speakers
                    oscillator.connect(context.destination);

                    // Start the oscillator now
                    oscillator.start(context.currentTime);

                    // Stop the oscillator after "DahLength" seconds from now
                    oscillator.stop(context.currentTime + _DahLength);
If you run your code now, you should have a working keyer.

I find that a _DitLength of 0.6 works better than 1. You can also tinker with the frequency.

With a little more programming, you could even have these values input by the user. And you may hear a bit of click in your tones; I do on my MacBook. But this is a simple program; I'll leave it to you to work out all the kinks.

Just in case I've left something out, or left something a little vague, here's the entire .html document for reference (I rearranged the order of the variables a bit):

<!doctype html>
<!-- From http://code.tutsplus.com/tutorials/the-web-audio-api-what-is-it--cms-23735 -->
<html>
    <head>
        <title>My Morse Code Keyer</title>
    </head>
    <body>
        <h1>Welcome to the Web Audio API</h1>
    <p>Press Down Arrow for Dit, Right Arrow for Dah.</p>

    <script>   
        // Duration of the dits and dahs
        var _DitLength = 0.06;
        var _DahLength = _DitLength * 3;
        var _Freq = 440;
        var _Dah = 37; // 37 = down arrow
        var _Dit = 39; // 39 = right arrow

        addEventListener("keydown", dealWithKeyboard, true);

        function dealWithKeyboard(event) {
//            alert(event.keyCode + " has been pressed");
            switch(event.keyCode) {
                    case _Dit:
//                    alert("down");

                    // Create the audio context
                    var context = new AudioContext();
                    var oscillator = context.createOscillator();
                    oscillator.frequency.value = _Freq;
 
                    // Connect the oscillator to our speakers
                    oscillator.connect(context.destination);

                    // Start the oscillator now
                    oscillator.start(context.currentTime);

                    // Stop the oscillator after "DitLength" seconds from now
                    oscillator.stop(context.currentTime + _DitLength);

                    break;

                case _Dah:
//                    alert("down");

                    // Create the audio context
                    var context = new AudioContext();
                    var oscillator = context.createOscillator();
                    oscillator.frequency.value = _Freq;
 
                    // Connect the oscillator to our speakers
                    oscillator.connect(context.destination);

                    // Start the oscillator now
                    oscillator.start(context.currentTime);

                    // Stop the oscillator after "DahLength" seconds from now
                    oscillator.stop(context.currentTime + _DahLength);

                    break;
            }
        }
    </script>
    </body>
</html>

Have fun playing with your new web-based Morse code keyer!

UPDATE: The full listing below, created 19-Jan-2023, and published at https://kentwest.neocities.org/coding/web/morse-keyer, is a better version.

<!doctype html>
<html lang="en">

    <head>
        <title>My Morse Code Keyer</title>
    </head>

    <body>
        <h1>Welcome to Kent's Web-based Morse Code Keyer!</h1>
        <p>Press the left arrow key for a dah, and the right arrow key for a dit.</p>
    
        <script>
            document.addEventListener("keydown", dealWithKeyboard, false);


            function playTone(DitOrDah) {
                const ditLength = 0.06;                     // Length of the Dit tone in seconds.
                const dahMultiplier = 3;                    // A dah is this many times as long as a dit.
                const freq = 440;                           // Frequency of tone, in Hertz.
                const waveType = "sine";                    // sine, square, sawtooth, triangle
                
                const soundBooth = new AudioContext();      // Creates a virtual recording studio, sort of.
                oscillator = soundBooth.createOscillator(); // Creates an oscillator.
                oscillator.type = waveType;                 // That generates this type of wave.
                oscillator.frequency.value = freq;          // At this frequency.
                oscillator.connect(soundBooth.destination); // Connects the output to the system's default speaker system.
                
                switch(DitOrDah) {
                    case "dit":       // If this function gets a dit, play oscillator for dit's length of time.
                        oscillator.start(soundBooth.currentTime);
                        oscillator.stop(soundBooth.currentTime + ditLength);
                        break;
                    case "dah":       // If a dah, then longer.
                        oscillator.start(soundBooth.currentTime);
                        oscillator.stop(soundBooth.currentTime + (ditLength * dahMultiplier));
                        break;
                }
            } // end of playTone()


            function dealWithKeyboard(event) {
                const dah = 37;             // 37 = left arrow
                const dit = 39;             // 39 = right arrow
                switch(event.keyCode) {
                    case dit:
                        playTone("dit");
                        break;
                    case dah:
                        playTone("dah");
                        break;
                }
            } // end of dealWithKeyboard()
        </script>
    </body>
</html>



Originally published at https://kentwest.blogspot.com/2016/06/a-simple-web-based-morse-code-keyer.html